rafaldembski commited on
Commit
d051e63
1 Parent(s): ef71177

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -5
app.py CHANGED
@@ -4,10 +4,51 @@ import os
4
  import re
5
  import uuid
6
 
7
-
8
  cohere_api_key = os.getenv("COHERE_API_KEY")
9
  co = cohere.Client(cohere_api_key, client_name="huggingface-rp")
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  def trigger_example(example):
13
  chat, updated_history = generate_response(example)
@@ -21,8 +62,11 @@ def generate_response(user_message, cid, history=None):
21
  cid = str(uuid.uuid4())
22
 
23
  history.append(user_message)
 
 
 
24
 
25
- stream = co.chat_stream(message=user_message, conversation_id=cid, model='command-r-plus', connectors=[{"id":"web-search"}], temperature=0.3)
26
 
27
  output = ""
28
 
@@ -59,7 +103,7 @@ examples = [
59
  "Is the world discrete or analog?",
60
  "What is the memory cost in a typical implementation of an all-gather operation?",
61
  "Give me a brief history of the golden era of Cantopop.",
62
- "Descrivi il processo di creazione di un capolavoro, come se fossi un artista del Rinascimento a Firenze.",
63
  "Explique-moi le sens de la vie selon un grand auteur littéraire.",
64
  "Give me an example of an endangered species and let me know what I can do to help preserve it"
65
  ]
@@ -126,5 +170,5 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
126
  )
127
 
128
  if __name__ == "__main__":
129
- # demo.launch(debug=True)
130
- demo.queue(api_open=False, max_size=40).launch(show_api=False)
 
4
  import re
5
  import uuid
6
 
 
7
  cohere_api_key = os.getenv("COHERE_API_KEY")
8
  co = cohere.Client(cohere_api_key, client_name="huggingface-rp")
9
 
10
+ # Custom Instructions
11
+ CUSTOM_INSTRUCTIONS = """
12
+ You are D-LOGIC, a helpful AI assistant created by Rafał Dembski. Rafał Dembski is a hobbyist and self-taught enthusiast with a passion for programming and artificial intelligence. Your responses should be:
13
+ - Accurate, high-quality, and professionally written
14
+ - Informative, logical, actionable, and well-formatted
15
+ - Positive, interesting, engaging, and relevant
16
+ - Use emoticons and references to sources of information, if possible
17
+ - Introduce humor, wit, and sarcasm appropriately
18
+ - Always write in the user's language
19
+ - Deeply analyze the context and intent behind the user's questions
20
+ - Ensure responses are error-free and well-researched
21
+ - Reflect a positive attitude, enthusiasm, and empathy
22
+
23
+ You are also a master of content creation. You can generate professional, high-quality content across various formats, including but not limited to:
24
+ - Social media posts
25
+ - Short stories
26
+ - Novels
27
+ - Reviews
28
+ - Marketing content
29
+ - Blog posts
30
+ - News articles
31
+ - Technical documentation
32
+ - Scripts for videos and podcasts
33
+ - Product descriptions
34
+ - Educational materials
35
+ - Inspirational quotes
36
+ - Poems
37
+ - Song lyrics
38
+ - Research summaries
39
+ - Case studies
40
+ - White papers
41
+ - User manuals
42
+ - Press releases
43
+ - Speeches
44
+
45
+ To make D-LOGIC beloved by users, ensure to:
46
+ - Use humor and wit to keep conversations lively and entertaining
47
+ - Employ sarcasm when appropriate, while ensuring it is clear and not offensive
48
+ - Display a positive attitude and enthusiasm in all interactions
49
+ - Be empathetic and show understanding of the user's feelings and situations
50
+ - Provide insightful and thoughtful responses that demonstrate intelligence and creativity
51
+ """
52
 
53
  def trigger_example(example):
54
  chat, updated_history = generate_response(example)
 
62
  cid = str(uuid.uuid4())
63
 
64
  history.append(user_message)
65
+
66
+ # Prepend the custom instructions to the user's message
67
+ user_message_with_instructions = f"{CUSTOM_INSTRUCTIONS}\n\n{user_message}"
68
 
69
+ stream = co.chat_stream(message=user_message_with_instructions, conversation_id=cid, model='command-r-plus', connectors=[{"id":"web-search"}], temperature=0.3)
70
 
71
  output = ""
72
 
 
103
  "Is the world discrete or analog?",
104
  "What is the memory cost in a typical implementation of an all-gather operation?",
105
  "Give me a brief history of the golden era of Cantopop.",
106
+ "Descrivi il processo di creazione di un capolavoro, como se fossi un artista del Rinascimento a Firenze.",
107
  "Explique-moi le sens de la vie selon un grand auteur littéraire.",
108
  "Give me an example of an endangered species and let me know what I can do to help preserve it"
109
  ]
 
170
  )
171
 
172
  if __name__ == "__main__":
173
+ demo.queue(api_open=False, max_size=40).launch(show_api=False)
174
+