Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ spring_ai/target/**
spring_ai/create_user.sql
spring_ai/drop.sql
src/client/spring_ai/target/classes/*
api_server_key
api_server_key
src/mcp/optimizer_settings_openai.json
65 changes: 43 additions & 22 deletions src/client/spring_ai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ Get Started with Java Development](https://docs.oracle.com/en/database/oracle/or

Download one of them through the `Download SpringAI` button. Unzip the content and set the executable permission on the `start.sh` with `chmod 755 ./start.sh`.

Edit `start.sh` to add only the DB_PASSWORD not exported, as in this example:
Edit `start.sh` to change the DB_PASSWORD or any other referece/credential changed by the dev env, as in this example:
```
export SPRING_AI_OPENAI_API_KEY=$OPENAI_API_KEY
export DB_DSN="jdbc:oracle:thin:@localhost:1521/FREEPDB1"
export DB_USERNAME=<DB_USER_NAME>
export DB_PASSWORD=""
export DB_PASSWORD=<DB_PASSWORD>
export DISTANCE_TYPE=COSINE
export OPENAI_CHAT_MODEL=gpt-4o-mini
export OPENAI_EMBEDDING_MODEL=text-embedding-3-small
Expand Down Expand Up @@ -54,13 +54,17 @@ Start with:

This project contains a web service that will accept HTTP GET requests at

* `http://localhost:9090/v1/chat/completions`: to use Vector Search via OpenAI REST API
* `http://localhost:9090/v1/chat/completions`: to use RAG via OpenAI REST API
* `http://localhost:9090/v1/models`: return models behind the RAG via OpenAI REST API
* `http://localhost:9090/v1/service/llm` : to chat straight with the LLM used
* `http://localhost:9090/v1/service/search/`: to search for document similar to the message provided
* `http://localhost:9090/v1/service/store-chunks/`: to embedd and store a list of text chunks in the vectorstore


Vector Search call example with `openai` build profile with no-stream:


### Completions
RAG call example with `openai` build profile with no-stream:

```
curl -N http://localhost:9090/v1/chat/completions \
Expand Down Expand Up @@ -119,23 +123,41 @@ curl -X POST http://localhost:9090/v1/service/store-chunks \
-d '["First chunk of text.", "Second chunk.", "Another example."]'
```

response:
### Get model name
Return the name of model used. It's useful to integrate ChatGUIs that require the model list before proceed.

```
[
[
-0.014500250108540058,
-0.03604526072740555,
0.035963304340839386,
0.010181647725403309,
-0.01610776223242283,
-0.021091962233185768,
0.03924199938774109,
..
]
]
curl http://localhost:9090/v1/models
```

## MCP RagTool
The completion service is also available as an MCP server based on the SSE transport protocol.
To test it:

* Start as usual the microservice:
```shell
./start.sh
```

* Start the MCP inspector:
```shell
export DANGEROUSLY_OMIT_AUTH=true
npx @modelcontextprotocol/inspector
```

* With a web browser open: http://127.0.0.1:6274

* Configure:
* Transport Type: SSE
* URL: http://localhost:9090/sse
* set Request Timeout to: 200000

* Test a call to `getRag` Tool.





## Oracle Backend for Microservices and AI
* Add in `application-obaas.yml` the **OPENAI_API_KEY**, if the deployement is based on the OpenAI LLM services:
```
Expand Down Expand Up @@ -248,11 +270,6 @@ it should return:
```







## Prerequisites

Before using the AI commands, make sure you have a developer token from OpenAI.
Expand All @@ -269,3 +286,7 @@ export SPRING_AI_OPENAI_API_KEY=<INSERT KEY HERE>
Setting the API key is all you need to run the application.
However, you can find more information on setting started in the [Spring AI reference documentation section on OpenAI Chat](https://docs.spring.io/spring-ai/reference/api/clients/openai-chat.html).





9 changes: 7 additions & 2 deletions src/client/spring_ai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@

<dependencies>

<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down Expand Up @@ -75,15 +80,15 @@
<version>23.5.0.24.07</version>
</dependency>

<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.spring</groupId>
<artifactId>oracle-spring-boot-starter-wallet</artifactId>
<version>23.4.0</version>
</dependency>
</dependency>

<!-- ORACLE DB END-->

Expand Down
Loading