Spaces:
Runtime error
Runtime error
broadfield-dev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -4,16 +4,17 @@ os.system("pip install ollama")
|
|
4 |
|
5 |
from ollama import chat
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
17 |
|
18 |
|
19 |
# Create a Gradio interface
|
|
|
4 |
|
5 |
from ollama import chat
|
6 |
|
7 |
+
def chat_with_ollama(prompt):
|
8 |
+
stream = chat(
|
9 |
+
model='llama3.2',
|
10 |
+
messages=[{'role': 'user', 'content': f'{prompt}'}],
|
11 |
+
stream=True,
|
12 |
+
)
|
13 |
+
output=""
|
14 |
+
for chunk in stream:
|
15 |
+
print(chunk['message']['content'], end='', flush=True)
|
16 |
+
output+=chunk['message']['content']
|
17 |
+
yield output
|
18 |
|
19 |
|
20 |
# Create a Gradio interface
|