| 105 | return data["choices"][0]["message"]["content"] |
| 106 | |
| 107 | def turn(history: list[dict], user: str) -> tuple[float, str]: |
| 108 | history.append({"role": "user", "content": user}) |
| 109 | msgs = [{"role": "system", "content": system}, *history] |
| 110 | payload = { |
| 111 | "model": "luce-dflash", |
| 112 | "messages": msgs, |
| 113 | "max_tokens": 8, |
| 114 | "stream": False, |
| 115 | } |
| 116 | t0 = time.time() |
| 117 | reply = chat_post(payload) |
| 118 | dt = time.time() - t0 |
| 119 | history.append({"role": "assistant", "content": reply}) |
| 120 | return dt, reply |
| 121 | |
| 122 | history: list[dict] = [] |
| 123 | |