Spaces:
Running
Running
from openai import OpenAI | |
import os | |
# Authenticate with token | |
token = os.getenv("OPENROUTER_TOKEN") | |
# client = OpenAI( | |
# base_url="https://openrouter.ai/api/v1", | |
# api_key=token, | |
# ) | |
# completion = client.chat.completions.create( | |
# model="google/gemma-3-27b-it:free", | |
# messages=[ | |
# { | |
# "role": "user", | |
# "content": [ | |
# {"type": "text", "text": "What is in this image?"}, | |
# { | |
# "type": "image_url", | |
# "image_url": { | |
# "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg" | |
# }, | |
# }, | |
# ], | |
# } | |
# ], | |
# ) | |
# print(completion.choices[0].message.content) | |
import requests | |
import json | |
response = requests.post( | |
url="https://openrouter.ai/api/v1/chat/completions", | |
headers={ | |
"Authorization": f"Bearer {token}", | |
"Content-Type": "application/json", | |
}, | |
data=json.dumps( | |
{ | |
"model": "google/gemma-3-27b-it:free", | |
"messages": [ | |
{ | |
"role": "user", | |
"content": [ | |
{ | |
"type": "text", | |
"text": """Ubah text Ringkasan Rekam Medis SOAP ini menjadi format FHIR HL7 JSON. ## Ringkasan Rekam Medis SOAP - """, | |
}, | |
], | |
} | |
], | |
} | |
), | |
) | |
print(response.text) | |