-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_code_for_groq.py
More file actions
52 lines (32 loc) · 933 Bytes
/
example_code_for_groq.py
File metadata and controls
52 lines (32 loc) · 933 Bytes
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
44
45
46
47
48
49
50
51
52
# terminal command to activate venv in windows: .\venv\Scripts\activate
# terminal command to activate venv in mac: source venv/bin/activate
# terminal command to install requirements: pip install -r requirements.txt
import os
import streamlit as st
from groq import Groq
client = Groq(
api_key=st.secrets["GROQ_API_CHATBOT"],
)
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Usage of git for open soruce",
}
],
model="llama3-8b-8192",
)
print(chat_completion.choices[0].message.content)
# from groq import Groq
# client = Groq()
# completion = client.chat.completions.create(
# model="llama3-8b-8192",
# messages=[],
# temperature=1,
# max_tokens=1024,
# top_p=1,
# stream=True,
# stop=None,
# )
# for chunk in completion:
# print(chunk.choices[0].delta.content or "", end="")