This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydantic import BaseModel | |
from anonLLM.llm import OpenaiLanguageModel | |
from dotenv import load_dotenv | |
load_dotenv() | |
llm = OpenaiLanguageModel(anonymize=False, temperature=1) | |
class Person(BaseModel): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain_openai import ChatOpenAI | |
from langchain_core.pydantic_v1 import BaseModel, Field | |
from dotenv import load_dotenv | |
load_dotenv() | |
class NextMove(BaseModel): | |
move: str = Field(..., description="Best next move to win the chess game. It should be in Standard Algebraic Notation") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dspy | |
from dspy.functional import TypedPredictor | |
from pydantic import BaseModel, Field | |
from typing import List | |
from dotenv import load_dotenv | |
class Task(BaseModel): | |
"Class for keeping track of a task" | |
name: str = Field(..., description="name of the task") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
from dotenv import load_dotenv | |
import os | |
load_dotenv() | |
BASE_URL = 'https://news.ycombinator.com' | |
USERNAME = os.getenv("USERNAME") | |
PASSWORD = os.getenv("PASSWORD") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
from st_chat_message import message | |
from dotenv import load_dotenv | |
import fitz | |
load_dotenv() | |
from raptor.raptor import RetrievalAugmentation # noqa | |
RA = RetrievalAugmentation() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = openai.ChatCompletion.create( | |
model=fine_tuned_model_id, messages=test_messages, temperature=0.5 | |
) | |
print(response["choices"][0]["message"]["content"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
training_response = openai.File.create( | |
file=open(training_file_name, "rb"), purpose="fine-tune" | |
) | |
training_file_id = training_response["id"] | |
validation_response = openai.File.create( | |
file=open(validation_file_name, "rb"), purpose="fine-tune" | |
) | |
validation_file_id = validation_response["id"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
# Load JSON data from mypoems.json | |
with open('mypoems.json', 'r') as json_file: | |
json_data = json.load(json_file) | |
# Conversion from JSON to JSONL | |
with open('mypoems.jsonl', 'w') as f: | |
for entry in json_data: | |
json_str = json.dumps(entry) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The goal of this program is to transform the poems.txt file into a well structured json file | |
from dotenv import load_dotenv | |
import json | |
import re | |
from anonLLM.llm import OpenaiLanguageModel | |
load_dotenv() | |
SEP = '---' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chess | |
import chess.engine | |
import os | |
import dspy | |
from pydantic import BaseModel, Field | |
from dspy.functional import TypedPredictor | |
from dotenv import load_dotenv | |
load_dotenv() |