File size: 1,016 Bytes
34332a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33e322c
34332a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import requests

# Environment variable for the token
token = "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"
endpoint = "https://models.github.ai/inference"
model = "openai/gpt-4.1"

def API_call(report):
    headers = {
        "Authorization": f"Bearer {token}",
        "Content-Type": "application/json"
    }

    body = {
        "messages": [
            {"role": "system", "content": ""},
            {"role": "user", "content": f"please structure this report into findings and impressions. Please be precise and just output the findings and impressions with no other text.Please keep the same length of the original report. Report:{report}"}
        ],
        "temperature": 1,
        "top_p": 1,
        "model": model
    }
    
    response = requests.post(f"{endpoint}/chat/completions", headers=headers, json=body)

    if not response.ok:
        raise Exception(response.json().get("error", "Unknown error"))

    data = response.json()
    return(data["choices"][0]["message"]["content"])