MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / predict

Function predict

examples/gradio_chat/local.py:18–36  ·  view source on GitHub ↗
(message, history)

Source from the content-addressed store, hash-verified

16
17
18def predict(message, history):
19 messages = []
20
21 for user_message, assistant_message in history:
22 messages.append({"role": "user", "content": user_message})
23 messages.append({"role": "assistant", "content": assistant_message})
24
25 messages.append({"role": "user", "content": message})
26
27 response = llama.create_chat_completion_openai_v1(
28 model=model, messages=messages, stream=True
29 )
30
31 text = ""
32 for chunk in response:
33 content = chunk.choices[0].delta.content
34 if content:
35 text += content
36 yield text
37
38
39js = """function () {

Callers

nothing calls this directly

Calls 2

appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…