Skip to content

Commit d489560

Browse files
Merge pull request #184 from oracle-samples/183-springai-docs
update springai docs
2 parents aa21e52 + b153c00 commit d489560

File tree

1 file changed

+91
-7
lines changed

1 file changed

+91
-7
lines changed

docs/content/advanced/springai.md

Lines changed: 91 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,103 @@ chmod 755 ./start.sh
3434
```bash
3535
export DB_PASSWORD=""
3636
```
37-
38-
* drop the table `SPRING_AI_VECTORS` if exists, on which it will be automatically converted and ingested the langchain table used to store the embeddings part of the Chatbot configuration:
37+
* The `<VECTOR_STORE>` created in the Oracle AI Optimizer and Toolkit will be automatically converted in a `<VECTOR_STORE>_SPRINGAI` table, and it will store the same data. If already exists it will be used without modification.
38+
If you want to start from scratch, drop the table `<VECTOR_STORE>_SPRINGAI`, running in sql:
3939

4040
```sql
41-
DROP TABLE SPRING_AI_VECTORS CASCADE CONSTRAINTS;
41+
DROP TABLE <VECTOR_STORE>_SPRINGAI CASCADE CONSTRAINTS;
4242
COMMIT;
4343
```
4444

45-
This microservice will expose the following REST endpoints:
45+
* This microservice will expose the following REST endpoints:
46+
47+
* `http://localhost:9090/v1/chat/completions`: to use RAG via OpenAI REST API
48+
* `http://localhost:9090/v1/service/llm` : to chat straight with the LLM used
49+
* `http://localhost:9090/v1/service/search/`: to search for document similar to the message provided
50+
* `http://localhost:9090/v1/service/store-chunks/`: to embedd and store a list of text chunks in the vectorstore
51+
52+
### Completions endpoint usage examples
53+
A RAG call example with `openai` build profile, with no-stream:
54+
55+
```
56+
curl -N http://localhost:9090/v1/chat/completions \
57+
-H "Content-Type: application/json" \
58+
-H "Authorization: Bearer your_api_key" \
59+
-d '{
60+
"model": "server",
61+
"messages": [{"role": "user", "content": "Can I use any kind of development environment to run the example?"}],
62+
"stream": false
63+
}'
64+
```
65+
66+
the response with RAG:
67+
68+
```
69+
{
70+
"choices": [
71+
{
72+
"message": {
73+
"content": "Yes, you can use any kind of development environment to run the example, but for ease of development, the guide specifically mentions using an integrated development environment (IDE). It uses IntelliJ IDEA Community version as an example for creating and updating the files for the application (see Document 96EECD7484D3B56C). However, you are not limited to this IDE and can choose any development environment that suits your needs."
74+
}
75+
}
76+
]
77+
}
78+
```
79+
80+
If you want to ask for a stream output, the request it should be:
81+
```
82+
curl -N http://localhost:9090/v1/chat/completions \
83+
-H "Content-Type: application/json" \
84+
-H "Authorization: Bearer your_api_key" \
85+
-d '{
86+
"model": "server",
87+
"messages": [{"role": "user", "content": "Can I use any kind of development environment to run the example?"}],
88+
"stream": true
89+
}'
90+
```
91+
92+
Or a request without RAG:
93+
```
94+
curl --get --data-urlencode 'message=Can I use any kind of development environment to run the example?' localhost:9090/v1/service/llm | jq .
95+
```
96+
97+
In this case, the response not grounded it could be:
98+
99+
```
100+
{
101+
"completion": "Yes, you can use various development environments to run examples, depending on the programming language and the specific example you are working with. Here are some common options:\n\n1. **Integrated Development Environments (IDEs)**:\n - **Visual Studio Code**: A versatile code editor that supports many languages through extensions.\n - **PyCharm**: Great for Python development.\n - **Eclipse**: Commonly used for Java development.\n - **IntelliJ IDEA**: Another popular choice for Java and other languages.\n - **Xcode**: For macOS and iOS development (Swift, Objective-C).\n\n2. **Text Editors**:\n - **Sublime Text**: A lightweight text editor with support for many languages.\n - **Atom**: A hackable text editor for the 21st century.\n - **Notepad++**: A free source code editor for Windows.\n\n3. **Command Line Interfaces**:\n - You can run"
102+
}
103+
```
104+
105+
### Add new text chunks in the vector store example
106+
Store additional text chunks in the vector store, along their vector embeddings:
107+
108+
```
109+
curl -X POST http://localhost:9090/v1/service/store-chunks \
110+
-H "Content-Type: application/json" \
111+
-d '["First chunk of text.", "Second chunk.", "Another example."]'
112+
```
113+
114+
response will be a list of vector embeddings created:
115+
116+
```
117+
[
118+
[
119+
-0.014500250108540058,
120+
-0.03604526072740555,
121+
0.035963304340839386,
122+
0.010181647725403309,
123+
-0.01610776223242283,
124+
-0.021091962233185768,
125+
0.03924199938774109,
126+
..
127+
],
128+
[
129+
..
130+
]
131+
]
132+
```
46133

47-
* `http://localhost:8080/v1/chat/completions`: to use RAG via OpenAI REST API
48-
* `http://localhost:8080/v1/service/llm`: to chat straight with the LLM used
49-
* `http://localhost:8080/v1/service/search/`: to search for document similar to the message provided
50134

51135
### Run in the Oracle Backend for Microservices and AI
52136

0 commit comments

Comments
 (0)