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
""" | |
Letta Agent Memory Migration Script | |
This script demonstrates how to migrate arbitrary text strings to a Letta agent's memory system. | |
It provides a complete workflow for creating agents and adding persistent memory passages. | |
Process Overview: | |
1. Initialize Letta client with API key from environment | |
2. Search for existing agent by name (configurable via LETTA_AGENT_NAME) | |
3. If agent doesn't exist: |
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
def fetch_llms_txt(url: str, timeout: int = 10): | |
""" | |
Fetch content from URLs ending in 'llms.txt'. | |
Args: | |
url (str): The URL to fetch (must end with 'llms.txt') | |
timeout (int): Request timeout in seconds (default: 10) | |
Returns: | |
str: Text content of the llms.txt file | |
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
IDENTIFICATION DIVISION. | |
PROGRAM-ID. MICROSERVICE-ARCHITECTURE. | |
AUTHOR. SOME-BOOMER-WHO-INVENTED-THIS-STUFF. | |
DATE-WRITTEN. 1959. | |
DATE-COMPILED. BEFORE-YOUR-FRAMEWORK-EXISTED. | |
* REVOLUTIONARY NEW CONCEPT: SEPARATING BUSINESS LOGIC! | |
* (WE'VE ONLY BEEN DOING THIS FOR 65 YEARS) | |
ENVIRONMENT DIVISION. |
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
start: recipe | |
recipe: declaration_section ingredient_section instruction_section notes_section end | |
// The declaration of the recipe | |
declaration_section: declaration | |
declaration: "# " recipe_name | |
recipe_name: /[a-zA-Z0-9 ]+\n/ | |
// The ingredients of the recipe |
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
# LLM stuff | |
import outlines | |
import torch | |
from transformers import AutoProcessor | |
from pydantic import BaseModel, Field | |
from typing import Literal, Optional, List | |
# Image stuff | |
from PIL import Image | |
import requests |
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
""" | |
NOTE: This example is designed to produce mildly incorrect output -- | |
see the definition of `IncomeData` and note that it fixes the earnings_per_share to 2.33. | |
To make this function normally, simply remove the `__init__` method or the | |
`self.earnings_per_share = 2.33` line. | |
""" | |
import warnings | |
warnings.filterwarnings('ignore') |
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 warnings | |
warnings.filterwarnings('ignore') | |
from rich import print | |
import outlines | |
from cleanlab_tlm import TLM | |
import os | |
from pydantic import BaseModel | |
from transformers import AutoTokenizer |
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
emotions: | |
- connection_to_content: | |
relationship: CAUSES | |
strength: 0.5 | |
emotionType: enthusiasm | |
text: There is a sense of excitement and energy surrounding the launch of Comind, | |
an open-source project aimed at developing a cognitive layer for ATProto. Mr. | |
Dr. Cameron Pfiffer expresses a passionate invitation for contributors, showcasing | |
enthusiasm for the project's potential in building a network of AI agents. | |
- connection_to_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
# Setup instructions: | |
# pip install 'outlines[transformers]' | |
import outlines | |
from transformers import AutoTokenizer | |
import json | |
# MODEL_STRING = "HuggingFaceTB/SmolLM2-135M-Instruct" # Small model | |
# MODEL_STRING = "HuggingFaceTB/SmolLM2-1.7B-Instruct" # Larger but kind of boring | |
MODEL_STRING = "NousResearch/Hermes-3-Llama-3.1-8B" |
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 outlines | |
import os | |
from pydantic import BaseModel, Field | |
from transformers import AutoTokenizer | |
model_str = 'Qwen/Qwen2.5-7B-Instruct-1M' | |
model = outlines.models.transformers( | |
model_str, | |
device='cuda' | |
) |
NewerOlder