williambarberjr commited on
Commit
5e289b7
·
verified ·
1 Parent(s): dc879be

Upload openAiServerCheck.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. openAiServerCheck.py +56 -0
openAiServerCheck.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
7
+ client = OpenAI(
8
+ api_key=openai_api_key,
9
+ base_url=openai_api_base,
10
+ )
11
+
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)