-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdivergency.py
51 lines (34 loc) · 1.22 KB
/
divergency.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from langchain_community.vectorstores import Chroma
from langchain_community.document_loaders import UnstructuredMarkdownLoader
from langchain_community.embeddings import OllamaEmbeddings
from langchain_community.chat_models import ChatOllama
from elevenlabs import generate, play, Voice, VoiceSettings, set_api_key
from pydub import AudioSegment
from pydub.playback import play
import threading
from ollama import Client
model = ChatOllama(model_name="wizard-vicuna-uncensored:30b")
speech = True
set_api_key("")
conv = [{"role": "system", "content": ""}]
def chat(input):
conv.append({"role": "user", "content": input})
# print(conversation)
for part in Client().chat(model='wizard-vicuna-uncensored:30b', messages=conv, stream=True):
try:
print(part['message']['content'], end='', flush=True)
except:
print(".")
def main():
while True:
user_input = input("Enter a prompt: ")
if not user_input:
exit()
print()
try:
response = chat(user_input)
print(response)
except Exception as e:
print(e)
if __name__ == '__main__':
main()