Skip to content

Commit d53142c

Browse files
committed
Merge remote-tracking branch 'origin/main'
# Conflicts: # IA/main.py
2 parents f7e2c93 + 3572370 commit d53142c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

IA/main.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import os
2+
from dotenv import load_dotenv
3+
from groq import Groq
4+
5+
# Carrega o arquivo .env
6+
load_dotenv()
7+
8+
# Lê a variável de ambiente
9+
api_key = os.getenv("GROQ_API_KEY")
10+
client = Groq(api_key=api_key)
11+
12+
print("chat ia com Groq iniciado!")
13+
print("Digite 'Sair' para encerrar")
14+
15+
while True:
16+
user_input = input("Voce: ")
17+
18+
if user_input .lower() == "sair":
19+
print("IA: Até mais")
20+
break
21+
22+
response = client.chat.completions.create(
23+
model = "llama-3.1-8b-instant",
24+
messages=[
25+
{
26+
"role": "system",
27+
"content": "Você é uma IA educada, clara e didática."
28+
},
29+
{
30+
"role": "user",
31+
"content": user_input
32+
}
33+
]
34+
)
35+
resposta = response.choices[0].message.content
36+
print(f'IA: {resposta}\n')

0 commit comments

Comments
 (0)