File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 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 ' )
You can’t perform that action at this time.
0 commit comments