File size: 1,398 Bytes
37d3a3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
text = open("resume_mmds/11NP1Fgf1hOP6pmX0HTbnq7GWY6eAyw4Y.pdf.mmd","r").read()
import json, os
import openai
from dotenv import load_dotenv
load_dotenv()
# openai.api_key = os.environ.get("OPENAI_API_KEY")
openai.api_base = "http://0.0.0.0:8080" 

def extract(content:str):
    choice =0
    response = openai.ChatCompletion.create(
        model="test",
        messages=[{"role": "user", "content": content}],
        functions=[
            {
                "name": "infoExtract",
                "description": "extract info from resume",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "linkedin_url": {"type": "string"},
                        "portfolio_url": {"type": "string"},
                        "github_url": {"type": "string"},
                        "stackoverflow_url": {"type": "string"},
                        "name": {"type": "string"},
                        
                    }
                },
            }
        ],
        function_call="auto",

    )

    message = response["choices"][0]["message"]

    if message.get("function_call"):
        function_name = message["function_call"]["name"]
        function_args = json.loads(message["function_call"]["arguments"])
        if function_name == "infoExtract":
            print(function_args)
            


extract(text)