Hansimov commited on
Commit
9d61879
1 Parent(s): 9e74f90

:recycle: [Refactor] Example Codes: Remove outdated snippets

Browse files
examples/chat_with_openai.py CHANGED
@@ -1,15 +1,10 @@
1
  from openai import OpenAI
2
 
 
3
  base_url = "http://localhost:22222"
4
  api_key = "sk-xxxxx"
5
 
6
-
7
  client = OpenAI(base_url=base_url, api_key=api_key)
8
-
9
- extra_body = {
10
- "invocation_id": 1,
11
- }
12
-
13
  response = client.chat.completions.create(
14
  model="precise",
15
  messages=[
@@ -19,15 +14,12 @@ response = client.chat.completions.create(
19
  }
20
  ],
21
  stream=True,
22
- extra_body=extra_body,
23
  )
24
 
25
- # print(response)
26
  for chunk in response:
27
  if chunk.choices[0].delta.content is not None:
28
  print(chunk.choices[0].delta.content, end="", flush=True)
29
  elif chunk.choices[0].finish_reason == "stop":
30
  print()
31
  else:
32
- # print(chunk)
33
  pass
 
1
  from openai import OpenAI
2
 
3
+ # If runnning this service with proxy, you might need to unset `http(s)_proxy`.
4
  base_url = "http://localhost:22222"
5
  api_key = "sk-xxxxx"
6
 
 
7
  client = OpenAI(base_url=base_url, api_key=api_key)
 
 
 
 
 
8
  response = client.chat.completions.create(
9
  model="precise",
10
  messages=[
 
14
  }
15
  ],
16
  stream=True,
 
17
  )
18
 
 
19
  for chunk in response:
20
  if chunk.choices[0].delta.content is not None:
21
  print(chunk.choices[0].delta.content, end="", flush=True)
22
  elif chunk.choices[0].finish_reason == "stop":
23
  print()
24
  else:
 
25
  pass
examples/chat_with_post.py CHANGED
@@ -7,7 +7,6 @@ import re
7
  chat_api = "http://localhost:22222"
8
  api_key = "sk-xxxxx"
9
  requests_headers = {}
10
-
11
  requests_payload = {
12
  "model": "precise",
13
  "messages": [
@@ -17,7 +16,6 @@ requests_payload = {
17
  }
18
  ],
19
  "stream": True,
20
- "invocation_id": 1,
21
  }
22
 
23
  with httpx.stream(
 
7
  chat_api = "http://localhost:22222"
8
  api_key = "sk-xxxxx"
9
  requests_headers = {}
 
10
  requests_payload = {
11
  "model": "precise",
12
  "messages": [
 
16
  }
17
  ],
18
  "stream": True,
 
19
  }
20
 
21
  with httpx.stream(