-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: fujitatomoya [email protected]
- Loading branch information
1 parent
5258495
commit 679ebf9
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from ollama import chat | ||
|
||
|
||
messages = [ | ||
{ | ||
'role': 'user', | ||
'content': 'Why is the sky blue?', | ||
}, | ||
{ | ||
'role': 'assistant', | ||
'content': "The sky is blue because of the way the Earth's atmosphere scatters sunlight.", | ||
}, | ||
{ | ||
'role': 'user', | ||
'content': 'What is the weather in Tokyo?', | ||
}, | ||
{ | ||
'role': 'assistant', | ||
'content': 'The weather in Tokyo is typically warm and humid during the summer months, with temperatures often exceeding 30°C (86°F). The city experiences a rainy season from June to September, with heavy rainfall and occasional typhoons. Winter is mild, with temperatures rarely dropping below freezing. The city is known for its high-tech and vibrant culture, with many popular tourist attractions such as the Tokyo Tower, Senso-ji Temple, and the bustling Shibuya district.', | ||
}, | ||
] | ||
|
||
while True: | ||
user_input = input('Chat with history: ') | ||
response = chat( | ||
'llama3.1', | ||
messages=messages | ||
+ [ | ||
{'role': 'user', 'content': user_input}, | ||
], | ||
) | ||
|
||
# Add the response to the messages to maintain the history | ||
messages.append( | ||
{'role': 'assistant', 'content': response.message.content}, | ||
) | ||
print(response.message.content + '\n') |