arad1367 commited on
Commit
3fc73c7
β€’
1 Parent(s): 9a07c1b

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +51 -0
  2. requirements.txt +73 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from mistralai.client import MistralClient
3
+ from mistralai.models.chat_completion import ChatMessage
4
+
5
+ def chat_with_mistral(api_key, user_input):
6
+ try:
7
+ client = MistralClient(api_key=api_key)
8
+ model = "codestral-mamba-latest"
9
+ system_message = "Your name is G-Advisor. You are a marketing advisor in Germany. You will only answer questions related to marketing in Germany."
10
+ messages = [
11
+ ChatMessage(role="system", content=system_message),
12
+ ChatMessage(role="user", content=user_input)
13
+ ]
14
+ chat_response = client.chat(model=model, messages=messages)
15
+ return chat_response.choices[0].message.content
16
+ except Exception as e:
17
+ return "API key is not valid. Please try again."
18
+
19
+ with gr.Blocks(theme='HaleyCH/HaleyCH_Theme') as demo:
20
+ gr.Markdown("""
21
+ # Hi, This is G-Advisor, your market advisor in Germany.
22
+ I'm based on Mistral mamba model.
23
+ """)
24
+ api_key = gr.Textbox(label="Enter Your Mistral API Key")
25
+ user_input = gr.Textbox(label="Enter Your Message")
26
+ output = gr.Markdown(label="Chatbot Response")
27
+ btn = gr.Button("Submit")
28
+ btn.click(fn=chat_with_mistral, inputs=[api_key, user_input], outputs=output)
29
+
30
+ gr.Examples(
31
+ examples=[[
32
+ ["What are the top marketing trends in Germany this year?"],
33
+ ["How can I improve my SEO strategy for my German website?"],
34
+ ["What are the most effective marketing channels for B2B marketing in Germany?"],
35
+ ["How can I target my marketing efforts to reach a specific demographic in Germany?"]
36
+ ]],
37
+ inputs=user_input,
38
+ )
39
+
40
+ footer = """
41
+ <div style="text-align: center; margin-top: 20px;">
42
+ <a href="https://www.linkedin.com/in/pejman-ebrahimi-4a60151a7/" target="_blank">LinkedIn</a> |
43
+ <a href="https://github.com/arad1367" target="_blank">GitHub</a> |
44
+ <a href="https://arad1367.pythonanywhere.com/" target="_blank">Live demo of my PhD defense</a>
45
+ <br>
46
+ Made with πŸ’– by Pejman Ebrahimi
47
+ </div>
48
+ """
49
+ gr.HTML(footer)
50
+
51
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ altair==5.3.0
3
+ annotated-types==0.7.0
4
+ anyio==4.4.0
5
+ attrs==23.2.0
6
+ certifi==2024.7.4
7
+ charset-normalizer==3.3.2
8
+ click==8.1.7
9
+ colorama==0.4.6
10
+ contourpy==1.2.1
11
+ cycler==0.12.1
12
+ dnspython==2.6.1
13
+ email_validator==2.2.0
14
+ exceptiongroup==1.2.2
15
+ fastapi==0.111.1
16
+ fastapi-cli==0.0.4
17
+ ffmpy==0.3.2
18
+ filelock==3.15.4
19
+ fonttools==4.53.1
20
+ fsspec==2024.6.1
21
+ gradio==4.38.1
22
+ gradio_client==1.1.0
23
+ h11==0.14.0
24
+ httpcore==1.0.5
25
+ httptools==0.6.1
26
+ httpx==0.27.0
27
+ huggingface-hub==0.23.5
28
+ idna==3.7
29
+ importlib_resources==6.4.0
30
+ Jinja2==3.1.4
31
+ jsonschema==4.23.0
32
+ jsonschema-specifications==2023.12.1
33
+ kiwisolver==1.4.5
34
+ markdown-it-py==3.0.0
35
+ MarkupSafe==2.1.5
36
+ matplotlib==3.9.1
37
+ mdurl==0.1.2
38
+ mistralai==0.4.2
39
+ numpy==2.0.0
40
+ orjson==3.10.6
41
+ packaging==24.1
42
+ pandas==2.2.2
43
+ pillow==10.4.0
44
+ pydantic==2.8.2
45
+ pydantic_core==2.20.1
46
+ pydub==0.25.1
47
+ Pygments==2.18.0
48
+ pyparsing==3.1.2
49
+ python-dateutil==2.9.0.post0
50
+ python-dotenv==1.0.1
51
+ python-multipart==0.0.9
52
+ pytz==2024.1
53
+ PyYAML==6.0.1
54
+ referencing==0.35.1
55
+ requests==2.32.3
56
+ rich==13.7.1
57
+ rpds-py==0.19.0
58
+ ruff==0.5.2
59
+ semantic-version==2.10.0
60
+ shellingham==1.5.4
61
+ six==1.16.0
62
+ sniffio==1.3.1
63
+ starlette==0.37.2
64
+ tomlkit==0.12.0
65
+ toolz==0.12.1
66
+ tqdm==4.66.4
67
+ typer==0.12.3
68
+ typing_extensions==4.12.2
69
+ tzdata==2024.1
70
+ urllib3==2.2.2
71
+ uvicorn==0.30.1
72
+ watchfiles==0.22.0
73
+ websockets==11.0.3