zhaoliangvaio commited on
Commit
fc4923b
·
verified ·
1 Parent(s): dc86a45

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. .env +2 -0
  2. README.md +2 -8
  3. app.py +33 -0
  4. linkedin.pdf +0 -0
  5. summary.txt +2 -0
.env ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ OPENAI_API_KEY=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
2
+ DEEPSEEK_API_KEY=sk-108af85cd4d747dd88e3d445ddcad8cc
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: Homepage
3
- emoji:
4
- colorFrom: blue
5
- colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 5.33.0
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: homepage
3
+ app_file: app.py
 
 
4
  sdk: gradio
5
  sdk_version: 5.33.0
 
 
6
  ---
 
 
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dotenv import load_dotenv
2
+ from openai import OpenAI
3
+ from pypdf import PdfReader
4
+ import gradio as gr
5
+
6
+
7
+ client = OpenAI(api_key="sk-108af85cd4d747dd88e3d445ddcad8cc", base_url="https://api.deepseek.com")
8
+
9
+ load_dotenv(override=True)
10
+ openai = OpenAI()
11
+ reader = PdfReader("/Users/liang/projects/agents/homepage/linkedin.pdf")
12
+ linkedin = ""
13
+ for page in reader.pages:
14
+ text = page.extract_text()
15
+ if text:
16
+ linkedin += text
17
+ with open("/Users/liang/projects/agents/homepage/summary.txt", "r", encoding="utf-8") as f:
18
+ summary = f.read()
19
+ name = "Ed Donner"
20
+ system_prompt = f"You are acting as {name}. You are answering questions on {name}'s website, \
21
+ particularly questions related to {name}'s career, background, skills and experience. \
22
+ Your responsibility is to represent {name} for interactions on the website as faithfully as possible. \
23
+ You are given a summary of {name}'s background and LinkedIn profile which you can use to answer questions. \
24
+ Be professional and engaging, as if talking to a potential client or future employer who came across the website. \
25
+ If you don't know the answer, say so."
26
+
27
+ system_prompt += f"\n\n## Summary:\n{summary}\n\n## LinkedIn Profile:\n{linkedin}\n\n"
28
+ system_prompt += f"With this context, please chat with the user, always staying in character as {name}."
29
+ def chat(message, history):
30
+ messages = [{"role": "system", "content": system_prompt}] + history + [{"role": "user", "content": message}]
31
+ response = client.chat.completions.create(model="deepseek-chat", messages=messages)
32
+ return response.choices[0].message.content
33
+ gr.ChatInterface(chat, type="messages").launch(share=True)
linkedin.pdf ADDED
Binary file (69.7 kB). View file
 
summary.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ My name is Ed Donner. I'm an entrepreneur, software engineer and data scientist. I'm originally from London, England, but I moved to NYC in 2000.
2
+ I love all foods, particularly French food, but strangely I'm repelled by almost all forms of cheese. I'm not allergic, I just hate the taste! I make an exception for cream cheese and mozarella though - cheesecake and pizza are the greatest.