Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -1,10 +1,24 @@
|
|
1 |
from flask import Flask
|
|
|
2 |
from langchain_community.llms import Ollama
|
3 |
|
4 |
app = Flask(__name__)
|
5 |
|
6 |
llm = Ollama(model="phi3")
|
7 |
|
8 |
-
@app.route(
|
9 |
-
def
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from flask import Flask
|
2 |
+
from flask import request
|
3 |
from langchain_community.llms import Ollama
|
4 |
|
5 |
app = Flask(__name__)
|
6 |
|
7 |
llm = Ollama(model="phi3")
|
8 |
|
9 |
+
@app.route('/completion', methods=['POST'])
|
10 |
+
def completion():
|
11 |
+
"""
|
12 |
+
{
|
13 |
+
user: <username>,
|
14 |
+
text: <text>
|
15 |
+
}
|
16 |
+
"""
|
17 |
+
|
18 |
+
message = request.get_json()
|
19 |
+
llm_output = llm.invoke(message['text'])
|
20 |
+
|
21 |
+
print(llm_output)
|
22 |
+
return llm_output
|
23 |
+
|
24 |
+
# curl -v -X POST 'http://127.0.0.1:8000/completion' --header 'Content-Type: application/json' --data '{"user": "test-user", "text": "What do you know about 3D graphics"}'
|