brackozi commited on
Commit
90c554e
1 Parent(s): 9d03f80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -12
app.py CHANGED
@@ -1,26 +1,33 @@
1
- import openai
2
  import os
3
  import gradio as gr
 
4
 
5
- openai.api_key = os.environ["OPENAI_API_KEY"]
 
 
 
 
 
 
 
 
6
 
7
  def get_recommendation(prompt, recommendation_type):
 
8
  if recommendation_type == "Letter of Recommendation":
9
  context = f"Write a formal Letter of Recommendation with a header and signature for a job addressed to hiring manager for a candidate who is male/he named Ziga who is a recruiting professional without mention of time worked together and follow this instructions: {prompt}"
10
  else:
11
  context = f"Write a Recommendation for LinkedIn for a candidate who is male/he named Ziga who is a recruiting professional without mention of time worked together and follow this instructions: {prompt}"
12
 
13
- response = openai.Completion.create(
14
- engine="text-davinci-003",
15
- prompt=context,
16
- temperature=0.6,
17
- max_tokens=3000,
18
- top_p=1,
19
- frequency_penalty=0,
20
- presence_penalty=0
21
  )
22
 
23
- return response.choices[0].text.strip()
24
 
25
  inputs = [
26
  gr.inputs.Radio(choices=["Letter of Recommendation", "LinkedIn Recommendation"], label="Recommendation Type"),
@@ -29,4 +36,4 @@ inputs = [
29
 
30
  outputs = gr.outputs.Textbox(label="Reply")
31
 
32
- gr.Interface(fn=get_recommendation, inputs=inputs, outputs=outputs, title="Recommendation Generator", description="Describe what you enjoyed and observed while working with Ziga. Choose the type of recommendation you want.", theme="compact").launch()
 
 
1
  import os
2
  import gradio as gr
3
+ import google.generativeai as palm
4
 
5
+ palm.configure(api_key=os.environ["YOUR_API_KEY"])
6
+
7
+ defaults = {
8
+ 'model': 'models/chat-bison-001',
9
+ 'temperature': 0.25,
10
+ 'candidate_count': 1,
11
+ 'top_k': 40,
12
+ 'top_p': 0.95,
13
+ }
14
 
15
  def get_recommendation(prompt, recommendation_type):
16
+ context = ""
17
  if recommendation_type == "Letter of Recommendation":
18
  context = f"Write a formal Letter of Recommendation with a header and signature for a job addressed to hiring manager for a candidate who is male/he named Ziga who is a recruiting professional without mention of time worked together and follow this instructions: {prompt}"
19
  else:
20
  context = f"Write a Recommendation for LinkedIn for a candidate who is male/he named Ziga who is a recruiting professional without mention of time worked together and follow this instructions: {prompt}"
21
 
22
+ messages = [context]
23
+ response = palm.chat(
24
+ **defaults,
25
+ context=context,
26
+ examples=[],
27
+ messages=messages
 
 
28
  )
29
 
30
+ return response.last
31
 
32
  inputs = [
33
  gr.inputs.Radio(choices=["Letter of Recommendation", "LinkedIn Recommendation"], label="Recommendation Type"),
 
36
 
37
  outputs = gr.outputs.Textbox(label="Reply")
38
 
39
+ gr.Interface(fn=get_recommendation, inputs=inputs, outputs=outputs, title="Recommendation Generator", description="Describe what you enjoyed and observed while working with Ziga. Choose the type of recommendation you want.", theme="compact").launch()