Search is not available for this dataset
repo_id stringlengths 12 110 | file_path stringlengths 24 164 | content stringlengths 3 89.3M | __index_level_0__ int64 0 0 |
|---|---|---|---|
public_repos | public_repos/permchain/README.md | # `permchain`
## Get started
`pip install permchain`
## Overview
PermChain is an alpha-stage library for building stateful, multi-actor applications with LLMs. It extends the [LangChain Expression Language](https://python.langchain.com/docs/expression_language/) with the ability to coordinate multiple chains (or ac... | 0 |
public_repos | public_repos/permchain/LICENSE | # PermChain License
By using the software, you agree to all of the terms and conditions below.
## Copyright License
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in ... | 0 |
public_repos | public_repos/permchain/poetry.toml | [virtualenvs]
in-project = true
[installer]
modern-installation = false
| 0 |
public_repos/permchain | public_repos/permchain/permchain/constants.py | CONFIG_KEY_SEND = "__pregel_send"
CONFIG_KEY_READ = "__pregel_read"
CHECKPOINT_KEY_VERSION = "__pregel_version"
CHECKPOINT_KEY_TS = "__pregel_ts"
| 0 |
public_repos/permchain | public_repos/permchain/permchain/utils.py | import enum
# Before Python 3.11 native StrEnum is not available
class StrEnum(str, enum.Enum):
"""A string enum."""
pass
| 0 |
public_repos/permchain | public_repos/permchain/permchain/__init__.py | from permchain.pregel import Channel, Pregel, ReservedChannels
from permchain.pregel.read import ChannelRead
__all__ = ["Channel", "Pregel", "ReservedChannels", "ChannelRead"]
| 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/channels/base.py | from abc import ABC, abstractmethod
from contextlib import asynccontextmanager, contextmanager
from datetime import datetime
from typing import (
Any,
AsyncGenerator,
Generator,
Generic,
Mapping,
Optional,
Sequence,
TypeVar,
)
from typing_extensions import Self
from permchain.constants... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/channels/context.py | from contextlib import asynccontextmanager, contextmanager
from typing import (
Any,
AsyncContextManager,
AsyncGenerator,
Callable,
ContextManager,
Generator,
Generic,
Optional,
Sequence,
Type,
)
from typing_extensions import Self
from permchain.channels.base import (
BaseC... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/channels/binop.py | from contextlib import contextmanager
from typing import Callable, Generator, Generic, Optional, Sequence, Type
from typing_extensions import Self
from permchain.channels.base import BaseChannel, EmptyChannelError, Value
class BinaryOperatorAggregate(Generic[Value], BaseChannel[Value, Value, Value]):
"""Stores ... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/channels/last_value.py | from contextlib import contextmanager
from typing import Generator, Generic, Optional, Sequence, Type
from typing_extensions import Self
from permchain.channels.base import (
BaseChannel,
EmptyChannelError,
InvalidUpdateError,
Value,
)
class LastValue(Generic[Value], BaseChannel[Value, Value, Value]... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/channels/__init__.py | from permchain.channels.binop import BinaryOperatorAggregate
from permchain.channels.context import Context
from permchain.channels.last_value import LastValue
from permchain.channels.topic import Topic
__all__ = [
"LastValue",
"Topic",
"Context",
"BinaryOperatorAggregate",
]
| 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/channels/topic.py | from contextlib import contextmanager
from typing import Any, Generator, Generic, Iterator, Optional, Sequence, Type, Union
from typing_extensions import Self
from permchain.channels.base import BaseChannel, Value
def flatten(values: Sequence[Value | list[Value]]) -> Iterator[Value]:
for value in values:
... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/checkpoint/base.py | import asyncio
from abc import ABC, abstractmethod
from typing import Any, Mapping, Sequence
from langchain.load.serializable import Serializable
from langchain.schema.runnable import RunnableConfig
from langchain.schema.runnable.utils import ConfigurableFieldSpec
from permchain.utils import StrEnum
class Checkpoin... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/checkpoint/memory.py | from typing import Any, Dict, Mapping, Sequence
from langchain.pydantic_v1 import Field
from langchain.schema.runnable import RunnableConfig
from langchain.schema.runnable.utils import ConfigurableFieldSpec
from permchain.checkpoint.base import BaseCheckpointAdapter
class MemoryCheckpoint(BaseCheckpointAdapter):
... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/pregel/log.py | import logging
logger = logging.getLogger(__name__)
| 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/pregel/validate.py | from typing import Any, Mapping, Sequence
from permchain.channels.base import BaseChannel
from permchain.channels.last_value import LastValue
from permchain.constants import CHECKPOINT_KEY_TS, CHECKPOINT_KEY_VERSION
from permchain.pregel.read import ChannelBatch, ChannelInvoke
from permchain.pregel.reserved import Res... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/pregel/debug.py | from pprint import pformat
from typing import Any, Iterator, Mapping
from langchain.schema.runnable import Runnable
from langchain.utils.input import get_bolded_text, get_colored_text
from permchain.channels.base import BaseChannel, EmptyChannelError
def print_step_start(step: int, next_tasks: list[tuple[Runnable, ... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/pregel/reserved.py | from enum import StrEnum
class ReservedChannels(StrEnum):
"""Channels managed by the framework."""
is_last_step = "is_last_step"
"""A channel that is True if the current step is the last step, False otherwise."""
| 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/pregel/read.py | from __future__ import annotations
from typing import Any, Callable, Mapping, Optional, Sequence
from langchain.pydantic_v1 import Field
from langchain.schema.runnable import (
Runnable,
RunnableConfig,
RunnableLambda,
RunnablePassthrough,
)
from langchain.schema.runnable.base import (
Other,
... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/pregel/write.py | from __future__ import annotations
from typing import Any, Callable, Sequence
from langchain.schema.runnable import (
Runnable,
RunnableConfig,
RunnablePassthrough,
)
from langchain.schema.runnable.utils import ConfigurableFieldSpec
from permchain.constants import CONFIG_KEY_SEND
TYPE_SEND = Callable[[S... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/pregel/io.py | from typing import Any, Iterator, Mapping, Sequence
from permchain.channels.base import BaseChannel
from permchain.pregel.log import logger
def map_input(
input_channels: str | Sequence[str], chunk: dict[str, Any] | Any
) -> Iterator[tuple[str, Any]]:
"""Map input chunk to a sequence of pending writes in the... | 0 |
public_repos/permchain/permchain | public_repos/permchain/permchain/pregel/__init__.py | from __future__ import annotations
import asyncio
import concurrent.futures
from collections import defaultdict, deque
from typing import (
Any,
AsyncIterator,
Awaitable,
Callable,
Iterator,
Mapping,
Optional,
Sequence,
Type,
Union,
cast,
overload,
)
from langchain.call... | 0 |
public_repos/permchain | public_repos/permchain/tests/test_pregel.py | import operator
import time
from concurrent.futures import ThreadPoolExecutor
from contextlib import contextmanager
from typing import Generator
import pytest
from langchain.schema.runnable import RunnablePassthrough
from pytest_mock import MockerFixture
from permchain import Channel, Pregel
from permchain.channels.b... | 0 |
public_repos/permchain | public_repos/permchain/tests/test_pregel_async.py | import asyncio
import operator
from contextlib import asynccontextmanager, contextmanager
from typing import Any, AsyncGenerator, AsyncIterator, Generator
import pytest
from langchain.schema.runnable import RunnablePassthrough
from pytest_mock import MockerFixture
from permchain import Channel, Pregel
from permchain.... | 0 |
public_repos/permchain | public_repos/permchain/tests/test_channels.py | import operator
from contextlib import asynccontextmanager, contextmanager
from typing import AsyncGenerator, Generator, Sequence, Union
import httpx
import pytest
from pytest_mock import MockerFixture
from permchain.channels.base import EmptyChannelError, InvalidUpdateError
from permchain.channels.binop import Binar... | 0 |
public_repos/permchain | public_repos/permchain/examples/draft-revise-loop.py | from __future__ import annotations
from langchain.chat_models.openai import ChatOpenAI
from langchain.output_parsers.openai_functions import JsonOutputFunctionsParser
from langchain.prompts import SystemMessagePromptTemplate
from langchain.schema.output_parser import StrOutputParser
from permchain import Channel, Pre... | 0 |
public_repos/permchain | public_repos/permchain/examples/readme.py | from permchain import Channel, Pregel
grow_value = (
Channel.subscribe_to("value")
| (lambda x: x + x)
| Channel.write_to(value=lambda x: x if len(x) < 10 else None)
)
app = Pregel(
chains={"grow_value": grow_value},
input="value",
output="value",
)
assert app.invoke("a") == "aaaaaaaa"
| 0 |
public_repos/permchain | public_repos/permchain/examples/combine_docs.ipynb | from langchain.chat_models.openai import ChatOpenAI
from langchain.prompts import ChatPromptTemplate, PromptTemplate
from langchain.schema.output_parser import StrOutputParser
from langchain.schema.runnable import Runnable, RunnablePassthrough
from langchain.schema.output_parser import StrOutputParser
from langchain.sc... | 0 |
public_repos/permchain | public_repos/permchain/examples/recursive-web-loader.py | from contextlib import asynccontextmanager, contextmanager
from typing import AsyncGenerator, Callable, FrozenSet, Generator, Optional, TypedDict
import httpx
from langchain.schema import Document
from langchain.schema.runnable import RunnableLambda, RunnablePassthrough
from langchain.utils.html import extract_sub_lin... | 0 |
public_repos/permchain | public_repos/permchain/examples/rag.py | from langchain.chat_models import ChatOpenAI
from langchain.embeddings import OpenAIEmbeddings
from langchain.prompts import PromptTemplate
from langchain.schema.messages import AIMessage, AnyMessage, FunctionMessage
from langchain.vectorstores import FAISS
from permchain import Channel, Pregel
from permchain.channels... | 0 |
public_repos/permchain/examples | public_repos/permchain/examples/old/web-research.ipynb | from operator import itemgetter
from langchain.chat_models import ChatOpenAI, ChatAnthropic
from langchain.prompts import SystemMessagePromptTemplate, ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser
from langchain.runnables.openai_functions import OpenAIFunctionsRouter
from permchain.con... | 0 |
public_repos/permchain/examples | public_repos/permchain/examples/old/example.ipynb | from operator import itemgetter
from langchain.chat_models.openai import ChatOpenAI
from langchain.prompts import SystemMessagePromptTemplate
from langchain.schema.output_parser import StrOutputParser
from langchain.runnables.openai_functions import OpenAIFunctionsRouter
from permchain.connection_inmemory import InMe... | 0 |
public_repos/permchain/examples/old | public_repos/permchain/examples/old/research/single_question_researcher.py | from typing import List
import requests
from fastapi import FastAPI
from langchain.chat_models import ChatAnthropic, ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser
from pydantic import BaseModel
from permchain.connection_inmemory import InMemoryP... | 0 |
public_repos/permchain/examples/old | public_repos/permchain/examples/old/research/webscraper.py | # main.py
from duckduckgo_search import DDGS
from fastapi import FastAPI
from langchain.document_loaders import AsyncHtmlLoader
from langchain.document_transformers import Html2TextTransformer
ddgs = DDGS()
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/query")
def read_i... | 0 |
public_repos/permchain/examples/old | public_repos/permchain/examples/old/research/researcher.py | from operator import itemgetter
import requests
from fastapi import FastAPI
from langchain.chat_models import ChatOpenAI
from langchain.output_parsers.openai_functions import JsonKeyOutputFunctionsParser
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser
from p... | 0 |
public_repos | public_repos/kork/poetry.lock | # This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand.
[[package]]
name = "accessible-pygments"
version = "0.0.4"
description = "A collection of accessible pygments styles"
category = "dev"
optional = false
python-versions = "*"
files = [
{file = "accessible-pygments-0.0.4.tar.g... | 0 |
public_repos | public_repos/kork/CONTRIBUTING.md | # Contributing to Kork
Thanks for your interest in contributing to Kork!
If you have ideas or features you would like to see implemented feel free to
open an issue and let me know.
PRs are welcome, but before starting to work on a substantial PR, please file
an issue to discuss the design and the code change.
## S... | 0 |
public_repos | public_repos/kork/pyproject.toml | [tool.poetry]
name = "kork"
version = "0.0.3"
description = "Natural Language Interfaces Powered by LLMs"
authors = ["LangChain"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/langchain-ai/kork"
[tool.poetry.dependencies]
python = "^3.8.1"
openai = "^0.27"
langchain = ">=0.0.110"
lark = "^1.1.5... | 0 |
public_repos | public_repos/kork/README.md | [](https://github.com/langchain-ai/kork/actions/workflows/test.yml)
# Kork 
`Kork` is an *experimental* [Langchain chain](https://python.langchain.com/en/latest/modules/ch... | 0 |
public_repos | public_repos/kork/LICENSE | MIT License
Copyright (c) 2023 Langchain AI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, dist... | 0 |
public_repos/kork | public_repos/kork/kork/foreign_funcs.py | """API to import foreign functions."""
import inspect
import sys
import types
import typing
from typing import Any, Callable, List, Mapping, Tuple, TypedDict
from kork import ast
PY_VERSION = (sys.version_info.major, sys.version_info.minor)
class FunctionInfo(TypedDict):
"""Information about a function."""
... | 0 |
public_repos/kork | public_repos/kork/kork/retrieval.py | """Logic that attempts to surface the most relevant information for writing code."""
from __future__ import annotations
import abc
import dataclasses
from typing import Callable, Sequence, Union
from kork import ast
from kork.foreign_funcs import to_extern_func_def
@dataclasses.dataclass(frozen=True)
class Abstract... | 0 |
public_repos/kork | public_repos/kork/kork/exceptions.py | """Definitions for custom Kork exceptions."""
class KorkException(Exception):
"""Generic Kork exception."""
class LLMParseException(KorkException):
"""Failed to parse LLM output."""
class KorkSyntaxException(KorkException):
"""Exceptions raised during syntax parsing."""
class KorkInterpreterExceptio... | 0 |
public_repos/kork | public_repos/kork/kork/examples.py | """Interface to specify kork examples easily."""
import abc
from typing import Any, Callable, List, Literal, Sequence, Tuple, Union
from kork import ast
from kork.ast_printer import AbstractAstPrinter
from kork.foreign_funcs import to_kork_function_call
from kork.utils import wrap_in_tag
def _add_result_variable(exp... | 0 |
public_repos/kork | public_repos/kork/kork/parser.py | # type:ignore[no-untyped-def]
"""Kork's default AST parser.
Kork uses Lark to parse the AST. The grammar follows closely
the one used in Crafting Interpreters for the Lox Programming Language.
https://craftinginterpreters.com/appendix-i.html#expressions
The grammar and parser were clobbered together in a few hours o... | 0 |
public_repos/kork | public_repos/kork/kork/interpreter.py | from typing import Any, Optional, Sequence, TypedDict, Union
from lark.exceptions import LarkError
from kork import ast
from kork.environment import Environment
from kork.exceptions import KorkRunTimeException
# TODO: Determine why mypy is not recognizing the import.
from kork.parser import parse # type: ignore[att... | 0 |
public_repos/kork | public_repos/kork/kork/display.py | """Utils for displaying chain results in a notebook."""
import base64
import math
from html import escape
from io import BytesIO
from typing import Any, Optional, Sequence, TypedDict, Union
from kork.ast_printer import AstPrinter
from kork.chain import CodeResult
from kork.parser import parse # type: ignore
try:
... | 0 |
public_repos/kork | public_repos/kork/kork/prompt_adapter.py | """A prompt adapter to allow working with both regular LLMs and Chat LLMs.
The prompt adapter supports breaking the prompt into:
1) Instruction Section
2) (Optional) Example Section
"""
from typing import Any, Callable, List, Sequence, Tuple
from langchain import BasePromptTemplate, PromptTemplate
from langchain.sch... | 0 |
public_repos/kork | public_repos/kork/kork/utils.py | import re
from typing import Optional
def wrap_in_tag(tag_name: str, content: str) -> str:
"""Wrap the content in an HTML style tag."""
return f"<{tag_name}>{content}</{tag_name}>"
def unwrap_tag(tag_name: str, text: str) -> Optional[str]:
"""Extract content located inside a tag."""
pattern = f"<{ta... | 0 |
public_repos/kork | public_repos/kork/kork/version.py | """Get the version of the package."""
from importlib import metadata
try:
__version__ = metadata.version("kork")
except metadata.PackageNotFoundError:
__version__ = "local"
| 0 |
public_repos/kork | public_repos/kork/kork/chain.py | """Implementation of a programming chain."""
from __future__ import annotations
from typing import (
Any,
Callable,
Dict,
List,
Mapping,
Optional,
Sequence,
Tuple,
TypedDict,
Union,
cast,
)
from langchain import LLMChain
from langchain.chains.base import Chain
from langchai... | 0 |
public_repos/kork | public_repos/kork/kork/ast.py | """The AST for the language.
The AST is a bit messy right now in terms of what's a statement vs. an expression,
and will likely need to be cleaned up a bit in the near future.
"""
from __future__ import annotations
import abc
import dataclasses
from typing import Any, Callable, Optional, Sequence, TypeVar, Union
T =... | 0 |
public_repos/kork | public_repos/kork/kork/ast_printer.py | import abc
from typing import Any, Union
from kork import ast
class AbstractAstPrinter(ast.Visitor, abc.ABC):
@abc.abstractmethod
def visit(
self, element: Union[ast.Stmt, ast.Expr], pretty_print: bool = False
) -> str:
"""Entry-point for printing the AST."""
class AstPrinter(AbstractAs... | 0 |
public_repos/kork | public_repos/kork/kork/environment.py | from __future__ import annotations
import copy
import dataclasses
from dataclasses import field
from typing import Any, Dict, List, Mapping, Optional, Sequence
from kork import ast
from kork.exceptions import KorkRunTimeException
@dataclasses.dataclass
class Environment:
"""Environment for storing variables and... | 0 |
public_repos/kork | public_repos/kork/kork/__init__.py | from kork import ast
from kork.ast_printer import AstPrinter
from kork.chain import CodeChain
from kork.environment import Environment
from kork.examples import (
AbstractExampleRetriever,
SimpleExampleRetriever,
c_,
format_examples,
r_,
)
from kork.exceptions import KorkException
from kork.interpre... | 0 |
public_repos/kork | public_repos/kork/tests/test_environment.py | import pytest
from kork import ast
from kork.environment import Environment
from kork.exceptions import KorkRunTimeException
def test_accessing_variables() -> None:
"""Test the instantiation of the environment."""
env = Environment()
with pytest.raises(KorkRunTimeException):
env.get_symbol("x")
... | 0 |
public_repos/kork | public_repos/kork/tests/test_prompt_adapter.py | from langchain.prompts import PromptTemplate
from kork.prompt_adapter import FewShotPromptValue, FewShotTemplate
def test_few_shot_template() -> None:
"""Test few shot template."""
prompt_template = PromptTemplate(
template="meow\n\n",
input_variables=[],
)
few_shot_template = FewShot... | 0 |
public_repos/kork | public_repos/kork/tests/test_ast.py | from kork.ast import _to_snake_case
def test_snake_case() -> None:
assert _to_snake_case("Number") == "number"
assert _to_snake_case("NumberWoof") == "number_woof"
| 0 |
public_repos/kork | public_repos/kork/tests/test_retrieval.py | from kork.ast import ExternFunctionDef, ParamList
from kork.retrieval import SimpleContextRetriever
def foo() -> None:
"""Do nothing."""
def bar(x: int) -> int:
"""Add one to x."""
return x + 1
def test_simple_retriever() -> None:
"""Test simple retriever"""
external_func = ExternFunctionDef(
... | 0 |
public_repos/kork | public_repos/kork/tests/test_chain.py | from kork import AstPrinter, CodeChain, SimpleContextRetriever, run_interpreter
from kork.examples import SimpleExampleRetriever
from kork.exceptions import KorkRunTimeException, LLMParseException
from kork.parser import parse # type: ignore
from .utils import ToyChatModel
def test_code_chain() -> None:
"""Test... | 0 |
public_repos/kork | public_repos/kork/tests/utils.py | from typing import Any, List, Optional
from langchain.chat_models.base import BaseChatModel
from langchain.schema import AIMessage, BaseMessage, ChatGeneration, ChatResult
from pydantic import Extra
class ToyChatModel(BaseChatModel):
response: str
class Config:
"""Configuration for this pydantic obj... | 0 |
public_repos/kork | public_repos/kork/tests/test_examples.py | from kork.ast_printer import AstPrinter
from kork.examples import c_, format_examples, r_
def add_(x: int, y: int) -> int:
"""Add two numbers."""
return x + y
def test_format_examples() -> None:
"""Test format examples."""
examples = [
(
"Add 1 and 2",
r_(c_(add_, 1, ... | 0 |
public_repos/kork | public_repos/kork/tests/test_utils.py | from kork.utils import unwrap_code, unwrap_tag, wrap_in_tag
def test_unwrap_tag() -> None:
"""Test unwrap_tag."""
# Test with an empty string
assert unwrap_tag("", "") is None
# Test with a string that doesn't contain the tag
assert unwrap_tag("table", "This is some text.") is None
# Test wi... | 0 |
public_repos/kork | public_repos/kork/tests/test_interpreter.py | from typing import Any
import pytest
from kork import ast
from kork.ast_printer import AstPrinter
from kork.environment import Environment
from kork.exceptions import KorkRunTimeException
from kork.interpreter import run_interpreter
# TODO: Determine why mypy is not recognizing the import.
from kork.parser import pa... | 0 |
public_repos/kork | public_repos/kork/tests/test_foreign_functions.py | from typing import Any, Literal, Mapping, Sequence, Union
from kork.ast import ExternFunctionDef, Param, ParamList
from kork.foreign_funcs import to_extern_func_def
# Do not type the function below. We're testing initialization of the retriever.
def foo(): # type: ignore
pass
def bar(x: int) -> int:
"""Ad... | 0 |
public_repos/kork | public_repos/kork/docs/make.bat | @ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set ... | 0 |
public_repos/kork | public_repos/kork/docs/Makefile | # Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@... | 0 |
public_repos/kork/docs | public_repos/kork/docs/source/examples.ipynb | %load_ext autoreload
%autoreload 2
import sys
sys.path.insert(0, "../")from kork.parser import parseexamples_as_strings = [
(
"declare a variable called `y` and assign to it the value 8",
"var y = 8",
)
]examples = [(query, parse(code)) for query, code in examples_as_strings]examplesfrom kork.... | 0 |
public_repos/kork/docs | public_repos/kork/docs/source/language.ipynb | %load_ext autoreload
%autoreload 2
import sys
sys.path.insert(0, "../")from kork import run_interpreterresult = run_interpreter("var x = 1; x = x * 10")
resultresult["environment"].variablesrun_interpreter("1 = 2")run_interpreter("x + 1")from kork import Environmentenv = Environment()env.set_symbol("x", 10)result = r... | 0 |
public_repos/kork/docs | public_repos/kork/docs/source/index.md | # Introduction
`Kork` is an *experimental* [Langchain chain](https://python.langchain.com/en/latest/modules/chains.html) that helps build natural language APIs powered by LLMs.
## Features
1. Assemble a natural language API from a set of python functions.
2. Generate a prompt to help the LLM write a **correct** prog... | 0 |
public_repos/kork/docs | public_repos/kork/docs/source/api.rst | .. _api:
.. currentmodule:: kork
API
----------
The main **Kork** API is shown here:
.. autosummary::
CodeChain
AstPrinter
AbstractContextRetriever
SimpleContextRetriever
AbstractExampleRetriever
SimpleExampleRetriever
Kork Interpreter
=================
.. autosummary::
InterpreterResult
ru... | 0 |
public_repos/kork/docs | public_repos/kork/docs/source/calculator.ipynb | %load_ext autoreload
%autoreload 2
import sys
sys.path.insert(0, "../")import math
import operator
import langchain
from langchain.llms import OpenAI
from kork import CodeChain
from kork.parser import parseexamples = [
("calculate the sqrt of 2", "let result = pow(2, 0.5)"),
("2*5 + 1", "let result = 2 * 5 +... | 0 |
public_repos/kork/docs | public_repos/kork/docs/source/introduction.ipynb | %load_ext autoreload
%autoreload 2
import sys
sys.path.insert(0, "../")import langchain
from langchain.chat_models import ChatOpenAI
from langchain.llms import OpenAI
from kork import CodeChaindef output_with_matplotlib(output: str) -> None:
"""Function that will output a plot using matplotlib."""
if not isi... | 0 |
public_repos/kork/docs | public_repos/kork/docs/source/ast.ipynb | %load_ext autoreload
%autoreload 2
import sys
sys.path.insert(0, "../")from kork.parser import parseparse("x")parse("x = 1")parse(
"""
extern fn foo() -> Any # Comment
x = 1; // Comment
y = x * x + foo()
"""
)from kork import AstPrinterprogram = parse(
"""
extern fn foo() -> Any # Comment
x=1; // Comment... | 0 |
public_repos/kork/docs | public_repos/kork/docs/source/prompt.ipynb | %load_ext autoreload
%autoreload 2
import sys
sys.path.insert(0, "../")import math
import langchain
from kork import (
CodeChain,
ast,
AstPrinter,
c_,
r_,
run_interpreter,
)
from langchain import PromptTemplate
from kork import SimpleContextRetrieverfrom typing import Any, List, Optional
from... | 0 |
public_repos/kork/docs | public_repos/kork/docs/source/query_analyzer.ipynb | %load_ext autoreload
%autoreload 2
import sys
sys.path.insert(0, "../")import langchain
from langchain.llms import OpenAI
from typing import List, Any
from kork import CodeChaindef gt(attribute: str, value: Any) -> Any:
"""Filter to where attribute > value"""
return {"attribute": attribute, "op": ">", "value"... | 0 |
public_repos/kork/docs | public_repos/kork/docs/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 0 |
public_repos/kork/docs | public_repos/kork/docs/source/retrievers.ipynb | %load_ext autoreload
%autoreload 2
import sys
sys.path.insert(0, "../")from typing import Any, List, Optional
from langchain.chat_models.base import BaseChatModel
from langchain.schema import AIMessage, BaseMessage, ChatGeneration, ChatResult
from pydantic import Extra
class ToyChatModel(BaseChatModel):
respon... | 0 |
public_repos/kork/docs/source | public_repos/kork/docs/source/examples/image_manipulation.ipynb | %load_ext autoreload
%autoreload 2
import sys
sys.path.insert(0, "../")from PIL import Image, ImageOps, ImageFilterdef resize(img: Image.Image, width: int, height: int) -> Image:
"""Use to resize an image to the given width and height"""
return img.resize((width, height))
def upscale(img: Image.Image, scale... | 0 |
public_repos | public_repos/youtube-insights/requirements.txt | streamlit>=1.26.0
langchain
openai
youtube-transcript-api
tiktoken
langchainhub
| 0 |
public_repos | public_repos/youtube-insights/streamlit_app.py | import os
from langchain import callbacks, hub
from langchain.chains import (
StuffDocumentsChain,
LLMChain,
ReduceDocumentsChain,
MapReduceDocumentsChain,
)
from langchain.chat_models import ChatOpenAI
from langchain.document_loaders import YoutubeLoader
from langchain.prompts import PromptTemplate
fr... | 0 |
public_repos | public_repos/youtube-insights/README.md | # 📦 Streamlit App Starter Kit
```
⬆️ (Replace above with your app's name)
```
Description of the app ...
## Demo App
[](https://app-starter-kit.streamlit.app/)
## GitHub Codespaces
[ --- only has .copy and .__array__ attributes of an array!!!
.typecode() --> .dtype.char
.iscontiguous() --> .flags['CONTIGUOUS'] or .flags.contiguous
.byteswapped() -> .byteswap()
.itemsize() -> .itemsize
.toscalar() -> .ite... | 0 |
public_repos | public_repos/datetime/DEV_README.txt | Thank you for your willingness to help make NumPy the best array system
available.
We have a few simple rules:
* try hard to keep the SVN repository in a buildable state and to not
indiscriminately muck with what others have contributed.
* Simple changes (including bug fixes) and obvious improvements are... | 0 |
public_repos | public_repos/datetime/MANIFEST.in | #
# Use .add_data_files and .add_data_dir methods in a appropriate
# setup.py files to include non-python files such as documentation,
# data, etc files to distribution. Avoid using MANIFEST.in for that.
#
include MANIFEST.in
include LICENSE.txt
include setupscons.py
include setupsconsegg.py
include setupegg.py
# Addin... | 0 |
public_repos | public_repos/datetime/TEST_COMMIT | oliphant: yes
rkern: yes
pearu: yes
fperez: yes
chanley: yes
cookedm: yes
swalton: yes
eric: yes
charris: no
fonnesbeck: no
afayolle: no
dubois: no
sasha: yes
tim_hochberg: yes
jarrod.millman: yes
ariver: 2010-01-14 20:02:18
| 0 |
public_repos | public_repos/datetime/release.sh | #! /bin/sh
# script to build tarballs, mac os x and windows installers on mac os x
paver bootstrap
source bootstrap/bin/activate
CFLAGS="-arch x86_64" FFLAGS="-arch x86_64" python setupsconsegg.py install
paver sdist
paver dmg -p 2.5
paver dmg -p 2.6
paver bdist_superpack -p 2.5
paver bdist_superpack -p 2.6
paver write... | 0 |
public_repos | public_repos/datetime/LICENSE.txt | Copyright (c) 2005-2009, NumPy Developers.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and... | 0 |
public_repos | public_repos/datetime/site.cfg.example | # This file provides configuration information about non-Python dependencies for
# numpy.distutils-using packages. Create a file like this called "site.cfg" next
# to your package's setup.py file and fill in the appropriate sections. Not all
# packages will use all sections so you should leave out sections that your
# ... | 0 |
public_repos | public_repos/datetime/pavement.py | """
This paver file is intented to help with the release process as much as
possible. It relies on virtualenv to generate 'bootstrap' environments as
independent from the user system as possible (e.g. to make sure the sphinx doc
is built against the built numpy, not an installed one).
Building a fancy dmg from scratch... | 0 |
public_repos | public_repos/datetime/README.txt | NumPy is the fundamental package needed for scientific computing with Python.
This package contains:
* a powerful N-dimensional array object
* sophisticated (broadcasting) functions
* tools for integrating C/C++ and Fortran code
* useful linear algebra, Fourier transform, and random number capabilitie... | 0 |
public_repos | public_repos/datetime/setupegg.py | #!/usr/bin/env python
"""
A setup.py script to use setuptools, which gives egg goodness, etc.
"""
from setuptools import setup
execfile('setup.py')
| 0 |
public_repos | public_repos/datetime/setup.py | #!/usr/bin/env python
"""NumPy: array processing for numbers, strings, records, and objects.
NumPy is a general-purpose array-processing package designed to
efficiently manipulate large multi-dimensional arrays of arbitrary
records without sacrificing too much speed for small multi-dimensional
arrays. NumPy is built ... | 0 |
public_repos | public_repos/datetime/setupscons.py | #!/usr/bin/env python
"""NumPy: array processing for numbers, strings, records, and objects.
NumPy is a general-purpose array-processing package designed to
efficiently manipulate large multi-dimensional arrays of arbitrary
records without sacrificing too much speed for small multi-dimensional
arrays. NumPy is built ... | 0 |
public_repos | public_repos/datetime/setupsconsegg.py | #!/usr/bin/env python
"""
A setup.py script to use setuptools, which gives egg goodness, etc.
"""
from setuptools import setup
execfile('setupscons.py')
| 0 |
public_repos | public_repos/datetime/INSTALL.txt | .. -*- rest -*-
.. vim:syntax=rest
.. NB! Keep this document a valid restructured document.
Building and installing NumPy
+++++++++++++++++++++++++++++
:Authors: Numpy Developers <numpy-discussion@scipy.org>
:Discussions to: numpy-discussion@scipy.org
.. Contents::
PREREQUISITES
=============
Building NumPy requir... | 0 |
public_repos | public_repos/datetime/THANKS.txt | Travis Oliphant for the NumPy core, the NumPy guide, various
bug-fixes and code contributions.
Paul Dubois, who implemented the original Masked Arrays.
Pearu Peterson for f2py, numpy.distutils and help with code
organization.
Robert Kern for mtrand, bug fixes, help with distutils, code
organization, strided... | 0 |
public_repos/datetime | public_repos/datetime/numpy/_import_tools.py | import os
import sys
__all__ = ['PackageLoader']
class PackageLoader:
def __init__(self, verbose=False, infunc=False):
""" Manages loading packages.
"""
if infunc:
_level = 2
else:
_level = 1
self.parent_frame = frame = sys._getframe(_level)
... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.