File size: 1,217 Bytes
00b0db9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a5cde82
 
 
00b0db9
 
 
a5cde82
 
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
import cohere
from typing import List, Dict
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) -> 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)."}, {"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