Skip to content

Instantly share code, notes, and snippets.

@tslmy
tslmy / README.md
Last active October 13, 2024 02:32
Together AI API issue

Discovered this unexpected behavior while using Together AI as an OpenAI-compatible API with LlamaIndex:

        Settings.llm = OpenAILike(
            model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
            api_base="https://api.together.xyz/v1",
            temperature=0.1,
            api_key=api_key,
            is_function_calling_model=True,
@tslmy
tslmy / main.py
Created September 8, 2024 20:51
Use llama3.1's function-calling capability as a drop-in replacement for OpenAI LLM in LlamaIndex agents
#!/usr/bin/env python
import random
from llama_index.agent.openai import OpenAIAgent
from llama_index.core import Settings
from llama_index.core.tools import FunctionTool
from llama_index.llms.openai_like import OpenAILike
from pydantic import Field
@tslmy
tslmy / main.py
Created March 26, 2024 05:02
Script to reproduce the neo4j dimensionality mismatch issue
from llama_index.core import (
Settings,
SimpleDirectoryReader,
StorageContext,
VectorStoreIndex,
)
from llama_index.legacy.vector_stores import Neo4jVectorStore
from llama_index.llms.ollama import Ollama
Settings.llm = Ollama(
@tslmy
tslmy / GitHubCheckHandler.py
Last active August 14, 2024 10:40
How to log messages from Python to GitHub as Checks within a Jenkinsfile
import logging
from datetime import datetime
from github import GitHubIntegration
class GitHubCheckHandler(logging.handler):
"""
A logging handler that sends messages to GitHub as a Check.
"""
@tslmy
tslmy / contract.yaml
Created October 15, 2022 06:59
OpenAPI 3.0 Contract of zgzgorg/iam-backend
openapi: 3.0.0
paths:
/account/approve_registers:
post:
responses:
"200":
description: approve accounts successful
"400":
description: approve accounts have some fails
summary: get account infomation from database
@tslmy
tslmy / build.gradle
Created September 16, 2022 19:09
To bump version numbers at release time with Gradle
plugins {
// The gradle-release plugin is designed to work similar to the Maven release plugin. (https://github.com/researchgate/gradle-release)
id 'net.researchgate.release' version '3.0.2'
}
@tslmy
tslmy / build.gradle
Created September 16, 2022 19:08
Gradle can simply read your Maven settings.xml for the credentials
plugins {
// Applies security defined for a repository in Maven's settings.xml file to MavenRepository elements in a Gradle build - both upload and download. (https://plugins.gradle.org/plugin/org.hibernate.build.maven-repo-auth)
id "org.hibernate.build.maven-repo-auth" version "3.0.4"
}
@tslmy
tslmy / settings.xml
Created September 16, 2022 19:08
Server authentication settings for Maven
<settings>
<servers>
<server>
<id>repo-for-snapshots</id>
<username>ming</username>
<password>{ABCDEFGHIJKLMNOP=}</password>
</server>
<server>
<id>repo-for-releases</id>
<username>ming</username>
@tslmy
tslmy / build.gradle
Created September 16, 2022 19:01
Defining your own Maven Repository server: Gradle
publishing {
publications {
// Defines a publication that sends the compiled Java component to Maven.
maven(MavenPublication) { from(components.java) }
}
repositories {
maven {
def type = version.endsWith('SNAPSHOT') ? 'snapshots' : 'releases'
name = "repo-for-${type}"
url = "https://example.com/repositories/${type}/"
@tslmy
tslmy / pom.xml
Created September 16, 2022 19:00
Defining your own Maven Repository server: Maven
<distributionManagement>
<snapshotRepository>
<id>repo-for-snapshots</id>
<name>Repository for Snapshots</name>
<url>https://example.com/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>repo-for-releases</id>
<name>Repository for Releases</name>
<url>https://example.com/repositories/releases/</url>