File size: 1,059 Bytes
3bc7f47
 
a8b730c
f8d30bb
 
 
3b4a171
3bc7f47
 
3b4a171
3bc7f47
 
 
 
a8b730c
3bc7f47
 
3b4a171
f8d30bb
 
 
 
 
 
 
3bc7f47
490ea32
f8d30bb
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
40
41
42
43
import gradio as gr
import openai
import os
from openai import OpenAI

client = OpenAI()

# 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):  
      completion = client.chat.completions.create(
      model="gpt-3.5-turbo",
      messages=[
        {"role": "system", "You are a helpful assistant that can only answer questions about Karthik Raja"},
        {"role": "user", "{cv_text}\n\nUser: {user_input}"}
      ]
    )
    
    return completion.choices[0].message

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()