Severian commited on
Commit
33af6ab
·
verified ·
1 Parent(s): 3e312b7

Update llm_handler.py

Browse files
Files changed (1) hide show
  1. llm_handler.py +9 -9
llm_handler.py CHANGED
@@ -2,12 +2,12 @@ from openai import OpenAI
2
  from params import OPENAI_MODEL, OPENAI_API_KEY
3
  import llamanet
4
 
 
 
 
5
  # Create an instance of the OpenAI class
6
  client = OpenAI(api_key=OPENAI_API_KEY)
7
 
8
- # Initialize LlamaNet client
9
- llamanet_client = llamanet.Client()
10
-
11
  def send_to_chatgpt(msg_list):
12
  try:
13
  completion = client.chat.completions.create(
@@ -31,18 +31,18 @@ def send_to_chatgpt(msg_list):
31
 
32
  def send_to_llamanet(msg_list):
33
  try:
34
- # Convert msg_list to the format expected by LlamaNet
35
- llamanet_messages = [{"role": msg["role"], "content": msg["content"]} for msg in msg_list]
36
 
37
  # Send request to LlamaNet
38
- response = llamanet_client.chat.completions.create(
39
- model="llamanet",
40
- messages=llamanet_messages,
41
  stream=True
42
  )
43
 
44
  llamanet_response = ""
45
- for chunk in response:
46
  if chunk.choices[0].delta.content is not None:
47
  llamanet_response += chunk.choices[0].delta.content
48
 
 
2
  from params import OPENAI_MODEL, OPENAI_API_KEY
3
  import llamanet
4
 
5
+ # Initialize LlamaNet
6
+ llamanet.run("start", "https://huggingface.co/arcee-ai/Arcee-Spark-GGUF/blob/main/Arcee-Spark-IQ4_XS.gguf")
7
+
8
  # Create an instance of the OpenAI class
9
  client = OpenAI(api_key=OPENAI_API_KEY)
10
 
 
 
 
11
  def send_to_chatgpt(msg_list):
12
  try:
13
  completion = client.chat.completions.create(
 
31
 
32
  def send_to_llamanet(msg_list):
33
  try:
34
+ # Create a new OpenAI client for LlamaNet (no API key needed)
35
+ llamanet_client = OpenAI()
36
 
37
  # Send request to LlamaNet
38
+ completion = llamanet_client.chat.completions.create(
39
+ model="gpt-3.5-turbo", # LlamaNet uses this as a placeholder
40
+ messages=msg_list,
41
  stream=True
42
  )
43
 
44
  llamanet_response = ""
45
+ for chunk in completion:
46
  if chunk.choices[0].delta.content is not None:
47
  llamanet_response += chunk.choices[0].delta.content
48