File size: 1,935 Bytes
58ac08a
 
87f3303
 
 
58ac08a
 
 
 
 
 
 
cd3d00e
 
58ac08a
 
 
 
 
 
 
 
 
aa822ad
58ac08a
20bb6e0
ea7688c
58ac08a
aa822ad
 
544fd4d
 
c82d03d
649ebd9
58ac08a
91522ee
58ac08a
aa822ad
7988374
 
 
6557d31
cd3d00e
 
 
 
 
 
6557d31
 
 
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
import os
from together import Together
from dotenv import load_dotenv

load_dotenv() 

class TogetherLLMLabeler:
    def __init__(self):
        self.client = Together(api_key=os.getenv("TOGETHER_API_KEY"))

    def generate_label(self, game_card, transcript, spatial_context, frame_urls):
        prompt = f"""
        Game information:
        This is a football game in seria A between Juventus and Empoli. Juventus is dressed in Dark Navy kit and the keeper is in orange, Empoli, the away team is dressed in white jersey and the keeper in fluorescent yellow. The referee is dressed in a red shirt and black shorts. The home team is Juventus-- the game is being played at the Allianz stadium.

        Commentary:
        {transcript}

        Instructions:
        - Summarize this event in factual soccer terminology.
        - Focus on the play's significance to the score.
        - Avoid exaggeration.
        """
        prompt = "hi how you doin"

        #images = [{"type": "image_url", "image_url": {"url": url}} for url in frame_urls]
        images = [{"type": "image_url", "image_url": {"url": frame_urls[1]}}]

        #content = [{"type": "text", "text": prompt}] + images
        content = [{"type": "text", "text": prompt}]
        messagez=[{"role": "user", "content": content}]
        print (messagez)
        response = self.client.chat.completions.create(
            model="meta-llama/Llama-Vision-Free",
            messages=[{"role": "user", "content": content}],
            #max_tokens=200
        )
#            messages=[{"role": "user", "content": content}],
        print(response.choices[0].message.content)
        #return response.choices[0].message["content"].strip()
        return response.choices[0].message.content
    

#before commentary:
#        Game Information:
#        {game_card}


#after commentary:
#        Spatial Context (object detections per frame):
#        {spatial_context}