File size: 1,778 Bytes
00b0db9
 
 
 
 
 
 
 
 
2c12930
00b0db9
 
0f227dc
00b0db9
 
 
2c12930
a5cde82
 
2c12930
 
 
 
 
55bb721
 
 
00b0db9
 
 
2c12930
55bb721
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
import cohere
from dotenv import load_dotenv
import os

load_dotenv()

cohere_api_key = os.getenv("cohere_api_key")
co = cohere.ClientV2(cohere_api_key)

def chat_completion(message: str, context: str) -> str:
    response = co.chat(
        model="command-r-plus-08-2024",
        messages=[{"role": "system", "content": "You are a Pokemon expert. You know everything about their characteristics, abilities, and evolutions. You always reply with the most accurate information, you are polite and helpful. Your output cannot be larger than 1500 characters (spaces included). Don't talk about things that the user did not mention in their message."}, {"role": "user", "content": message}, {"role": "assistant", "content": context}],
    ) 
    return response.message.content[0].text

def card_completion(message: str) -> str:
    response = co.chat(
        model="command-r-plus-08-2024",
        messages=[{"role": "system", "content": "You are an expert in Pokemon cards. You know everything about their characteristics, abilities, and evolutions. You always reply with the most accurate information, you are polite and helpful."}, {"role": "user", "content": message}],
    ) 
    return response.message.content[0].text

def summarize(message, system_prompt="You are an helpful assistant whose job is to summarize the text you are given in less than 900 charachters (including spaces) in such a way that it would constitute an effective and engaging description of a pokemon card package"):
        response = co.chat(
            model="command-r-plus-08-2024",
            messages=[
                {"role": "system", "content": system_prompt},
                {"role": "user", "content": message},
            ]
        )
        return response.message.content[0].text