broadfield-dev commited on
Commit
c262d21
·
verified ·
1 Parent(s): 55b26e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -4,16 +4,17 @@ os.system("pip install ollama")
4
 
5
  from ollama import chat
6
 
7
- stream = chat(
8
- model='llama3.2',
9
- messages=[{'role': 'user', 'content': 'Why is the sky blue?'}],
10
- stream=True,
11
- )
12
- output=""
13
- for chunk in stream:
14
- print(chunk['message']['content'], end='', flush=True)
15
- output+=chunk['message']['content']
16
- yield output
 
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