williambarberjr commited on
Commit
3ddf4a0
·
verified ·
1 Parent(s): 9378174

Upload openAiServerCheck.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. 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
- # Set OpenAI's API key and API base to use vLLM's API server.
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
- # {"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:
16
- # <tool_call>
17
- # {"name": <function-name>,"arguments": <args-dict>}
18
- # </tool_call>
19
 
20
- # Here are the available tools:
21
- # <tools> {
22
- # "name": "create_new_user",
23
- # "description": "Creates a new user in the database with the provided username, email, and encrypted password.",
24
- # "parameters": {
25
- # "properties": {
26
- # "username": {
27
- # "type": "string",
28
- # "description": "The username for the new user."
29
- # },
30
- # "email": {
31
- # "type": "string",
32
- # "description": "The email address for the new user.",
33
- # "format": "email"
34
- # },
35
- # "password": {
36
- # "type": "string",
37
- # "description": "The password for the new user which will be encrypted before storage."
38
- # }
39
- # },
40
- # "required": [
41
- # "username",
42
- # "email",
43
- # "password"
44
- # ]
45
- # },
46
- # "required": [
47
- # "username",
48
- # "email",
49
- # "password"
50
- # ]
51
- # } </tools>"""},
52
- {"role": "user", "content": """Who's the president of the France?"""}]
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
- print("Chat response:", chat_response)
 
 
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)