langchain
langchain-google-genai
tavily-python
openai
langchain-openai
langgraph
PyPDF2
pandas
tavily-python
langchain-google-genai
tavily-python
openai
langchain-openai
langgraph
PyPDF2
pandas
tavily-python
🍓2🔥1
import requests
from openai import OpenAI
class Contest:
def __init__(self, api_token):
self.api_token = api_token
self.model = "gpt-4.1-mini"
self.client = OpenAI(api_key=self.api_token, base_url="https://api.metisai.ir/openai/v1")
def capture_the_flag(self, question):
response = self.client.chat.completions.create(
model=self.model,
messages=[{"role": "user", "content": f"calculate {question}. just print answer"}],
max_tokens=100,
temperature=0.1
)
return response.choices[0].message.content.strip()
if __name__ == __main__:
API_KEY="your api key here"
input_question=input()
solver=Contest(API_KEY)
result=solver.capture_the_flag(input_question)
print(result)
🍓2❤1
import requests
import os
import re
from openai import OpenAI
from langgraph.prebuilt import create_react_agent
def request_url(url: str):
"""requests to the given URL and scrapes the HTML."""
scrape_request = requests.get(url, timeout=20)
if scrape_request.status_code == 200:
return scrape_request.text
return "Couldn't scrape the URL."
class Contest:
def __init__(self, api_token):
self.api_token = api_token
self.model = "gpt-4.1-mini"
self.client = OpenAI(api_key=self.api_token,
base_url="https://api.metisai.ir/openai/v1")
self.assistant = create_react_agent(
model="openai:gpt-4.1-mini",
tools=[request_url],
prompt="You are a helpful assistant who answers the users questions. Request to the API endpoint if the user requests and answer the user. You MUST write the final answer to the user's question in between brackets as short as possbile such as [12] or [south].",
)
def capture_the_flag(self, question):
response = self.assistant.invoke({"messages": {
"role": "user",
"content": question,
}})["messages"][-1].content.strip()
return re.findall(r'\[.+\]', response)[-1][1:-1]
🍓2
Please open Telegram to view this post
VIEW IN TELEGRAM
🍓7👍2
امین کافی
رسول کامکار
محمدرضا میردامادیان
امیررضا چمی
مهدی سمسارزاده
محمدصالح مهدینژاد
متین اکبری
محمدمهدی حیدری
محمدرضا خاشعی
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥15🍓1
Please open Telegram to view this post
VIEW IN TELEGRAM
❤17🍓6