robinroy03 commited on
Commit
2b330e8
·
verified ·
1 Parent(s): d41000c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +17 -3
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("/<lol>")
9
- def test(lol):
10
- return llm.invoke(lol)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"}'