Spaces:
Running
Running
File size: 1,624 Bytes
bc268ae f46cb11 bc268ae c235745 bc268ae |
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 52 53 54 55 56 57 |
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)
|