thanglekdi commited on
Commit
b2f52c9
·
1 Parent(s): b001e93

openAI done

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -5,7 +5,6 @@ import openai # type: ignore
5
  # openai.api_key = "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"
6
  client = openai.OpenAI()
7
  def respond(message, history: list[tuple[str, str]], system_message, max_tokens, temperature, top_p):
8
-
9
  #make history
10
  messages = [{"role": "system", "content": system_message}]
11
  for val in history:
@@ -14,7 +13,7 @@ def respond(message, history: list[tuple[str, str]], system_message, max_tokens,
14
  if val[1]:
15
  messages.append({"role": "assistant", "content": val[1]})
16
  messages.append({"role": "user", "content": message})
17
- print("Messages: \n", messages)
18
 
19
  #input
20
  response = client.responses.create(
@@ -25,7 +24,7 @@ def respond(message, history: list[tuple[str, str]], system_message, max_tokens,
25
  max_output_tokens=max_tokens
26
  )
27
  response = response.output_text
28
- print("Response: ", response)
29
  print("\n")
30
  yield response
31
 
 
5
  # openai.api_key = "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"
6
  client = openai.OpenAI()
7
  def respond(message, history: list[tuple[str, str]], system_message, max_tokens, temperature, top_p):
 
8
  #make history
9
  messages = [{"role": "system", "content": system_message}]
10
  for val in history:
 
13
  if val[1]:
14
  messages.append({"role": "assistant", "content": val[1]})
15
  messages.append({"role": "user", "content": message})
16
+ print("## Messages: \n", messages)
17
 
18
  #input
19
  response = client.responses.create(
 
24
  max_output_tokens=max_tokens
25
  )
26
  response = response.output_text
27
+ print("## Response: ", response)
28
  print("\n")
29
  yield response
30