williambarberjr
commited on
Upload openAiServerCheck.py with huggingface_hub
Browse files- openAiServerCheck.py +42 -39
openAiServerCheck.py
CHANGED
@@ -1,6 +1,8 @@
|
|
|
|
|
|
1 |
#vllm serve "/root/llama_3.1_8b_function_calling/checkpoint-669" --chat-template /root/template_chatml.jinja
|
2 |
from openai import OpenAI
|
3 |
-
|
4 |
openai_api_key = "EMPTY"
|
5 |
openai_api_base = "http://localhost:8000/v1"
|
6 |
|
@@ -12,45 +14,46 @@ client = OpenAI(
|
|
12 |
chat_response = client.chat.completions.create(
|
13 |
model="/root/llama_3.1_8b_function_calling/checkpoint-669",
|
14 |
messages=[
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
{"role": "user", "content": "
|
53 |
# {"role": "assistant", "content": """Sure, I can help with that. I'll need some details from you. Can you provide the username, email, and password you'd like to use?"""},
|
54 |
# {"role": "user", "content": """Sure, here they are: username: johndoe, email: [email protected], password: password123"""}]
|
55 |
)
|
56 |
-
|
|
|
|
1 |
+
#run these two commands to get setup (adjust the string after serve to point to the folder with the model):
|
2 |
+
#pip install vllm
|
3 |
#vllm serve "/root/llama_3.1_8b_function_calling/checkpoint-669" --chat-template /root/template_chatml.jinja
|
4 |
from openai import OpenAI
|
5 |
+
|
6 |
openai_api_key = "EMPTY"
|
7 |
openai_api_base = "http://localhost:8000/v1"
|
8 |
|
|
|
14 |
chat_response = client.chat.completions.create(
|
15 |
model="/root/llama_3.1_8b_function_calling/checkpoint-669",
|
16 |
messages=[
|
17 |
+
{"role": "system", "content": """You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions. For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
|
18 |
+
<tool_call>
|
19 |
+
{"name": <function-name>,"arguments": <args-dict>}
|
20 |
+
</tool_call>
|
21 |
|
22 |
+
Here are the available tools:
|
23 |
+
<tools> {
|
24 |
+
"name": "create_new_user",
|
25 |
+
"description": "Creates a new user in the database with the provided username, email, and encrypted password.",
|
26 |
+
"parameters": {
|
27 |
+
"properties": {
|
28 |
+
"username": {
|
29 |
+
"type": "string",
|
30 |
+
"description": "The username for the new user."
|
31 |
+
},
|
32 |
+
"email": {
|
33 |
+
"type": "string",
|
34 |
+
"description": "The email address for the new user.",
|
35 |
+
"format": "email"
|
36 |
+
},
|
37 |
+
"password": {
|
38 |
+
"type": "string",
|
39 |
+
"description": "The password for the new user which will be encrypted before storage."
|
40 |
+
}
|
41 |
+
},
|
42 |
+
"required": [
|
43 |
+
"username",
|
44 |
+
"email",
|
45 |
+
"password"
|
46 |
+
]
|
47 |
+
},
|
48 |
+
"required": [
|
49 |
+
"username",
|
50 |
+
"email",
|
51 |
+
"password"
|
52 |
+
]
|
53 |
+
} </tools>"""},
|
54 |
+
{"role": "user", "content": "Hey, I need to create a new account for our project management system. Can you help me with that?"}]
|
55 |
# {"role": "assistant", "content": """Sure, I can help with that. I'll need some details from you. Can you provide the username, email, and password you'd like to use?"""},
|
56 |
# {"role": "user", "content": """Sure, here they are: username: johndoe, email: [email protected], password: password123"""}]
|
57 |
)
|
58 |
+
|
59 |
+
print("Chat response:", chat_response)
|