File size: 948 Bytes
3bc7f47
 
a8b730c
3b4a171
3bc7f47
 
3b4a171
3bc7f47
 
 
 
a8b730c
3bc7f47
 
3b4a171
3bc7f47
 
 
 
 
 
 
 
 
3b4a171
3bc7f47
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import openai
import os

# Load your OpenAI API key from the environment variable
openai.api_key = os.getenv("OPENAI_API_KEY")

# Read the static CV file
def load_cv():
    with open("templated_CV.txt", 'r') as file:
        return file.read()

# Extract information from the CV
cv_text = load_cv()

def chat_with_ai(user_input):
    prompt = f"{cv_text}\n\nUser: {user_input}\nAI:"
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=[
            {"role": "user", "content": prompt}
        ]
    )
    return response.choices[0].message['content']

def main(user_input):
    response = chat_with_ai(user_input)
    return response

iface = gr.Interface(
    fn=main,
    inputs=gr.Textbox(label="Ask a question, that you would like to ask Karthik"),
    outputs="text",
    title="AI Clone",
    description="Interact with an AI clone for recruiting or for fun :) "
)

iface.launch()