MCPcopy Create free account
hub / github.com/CCCpan/ai-api-integration / chat

Function chat

src/python/chat.py:28–41  ·  view source on GitHub ↗
(history, model)

Source from the content-addressed store, hash-verified

26
27
28def chat(history, model):
29 stream = client.chat.completions.create(
30 model=model,
31 messages=history,
32 stream=True,
33 )
34 chunks = []
35 for chunk in stream:
36 delta = chunk.choices[0].delta
37 if delta.content:
38 print(delta.content, end="", flush=True)
39 chunks.append(delta.content)
40 print()
41 return "".join(chunks)
42
43
44def generate_image(prompt):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected