MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / convert_chat

Function convert_chat

examples/server/api_like_OAI.py:36–54  ·  view source on GitHub ↗
(messages)

Source from the content-addressed store, hash-verified

34
35#convert chat to prompt
36def convert_chat(messages):
37 prompt = "" + args.chat_prompt.replace("\\n", "\n")
38
39 system_n = args.system_name.replace("\\n", "\n")
40 user_n = args.user_name.replace("\\n", "\n")
41 ai_n = args.ai_name.replace("\\n", "\n")
42 stop = args.stop.replace("\\n", "\n")
43
44
45 for line in messages:
46 if (line["role"] == "system"):
47 prompt += f"{system_n}{line['content']}"
48 if (line["role"] == "user"):
49 prompt += f"{user_n}{line['content']}"
50 if (line["role"] == "assistant"):
51 prompt += f"{ai_n}{line['content']}{stop}"
52 prompt += ai_n.rstrip()
53
54 return prompt
55
56def make_postData(body, chat=False, stream=False):
57 postData = {}

Callers 1

make_postDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected