(history, model)
| 26 | |
| 27 | |
| 28 | def 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 | |
| 44 | def generate_image(prompt): |