repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
grapeot/devin.cursorrules | import unittest
from unittest.mock import patch, MagicMock
import sys
from io import StringIO
from tools.search_engine import search
class TestSearchEngine(unittest.TestCase):
def setUp(self):
# Capture stdout and stderr for testing
self.stdout = StringIO()
self.stderr = StringIO()
... | self.stderr.getvalue()) | self.assertIn | func_call | tests/test_search_engine.py | test_no_results | TestSearchEngine | 79 | null |
grapeot/devin.cursorrules | import os
import pytest
from unittest.mock import patch, MagicMock, mock_open, AsyncMock
from tools.screenshot_utils import take_screenshot_sync, take_screenshot
from tools.llm_api import query_llm
class TestScreenshotVerification:
def mock_page(self):
"""Mock Playwright page object."""
mock_page ... | b'fake_screenshot_data' | assert | string_literal | tests/test_screenshot_verification.py | test_screenshot_capture | TestScreenshotVerification | 65 | null |
grapeot/devin.cursorrules | import unittest
from unittest.mock import patch, MagicMock, mock_open
from tools.llm_api import create_llm_client, query_llm, load_environment
import os
import google.generativeai as genai
import io
import sys
def is_llm_configured():
"""Check if LLM is configured by trying to connect to the server"""
try:
... | "Test OpenAI response") | self.assertEqual | string_literal | tests/test_llm_api.py | test_query_openai | TestLLMAPI | 235 | null |
grapeot/devin.cursorrules | import unittest
from unittest.mock import patch, MagicMock, mock_open
from tools.llm_api import create_llm_client, query_llm, load_environment
import os
import google.generativeai as genai
import io
import sys
def is_llm_configured():
"""Check if LLM is configured by trying to connect to the server"""
try:
... | "Test Anthropic response") | self.assertEqual | string_literal | tests/test_llm_api.py | test_query_anthropic | TestLLMAPI | 284 | null |
grapeot/devin.cursorrules | import unittest
from unittest.mock import patch, MagicMock
import sys
from io import StringIO
from tools.search_engine import search
class TestSearchEngine(unittest.TestCase):
def setUp(self):
# Capture stdout and stderr for testing
self.stdout = StringIO()
self.stderr = StringIO()
... | output) | self.assertIn | variable | tests/test_search_engine.py | test_successful_search | TestSearchEngine | 53 | null |
MaxHalford/prince | from __future__ import annotations
import math
import tempfile
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
from scipy import sparse
import prince
from tests import load_df_... | P["% of variance"]) | assert_* | complex_expr | tests/test_ca.py | test_eigenvalues | TestCA | 95 | null |
MaxHalford/prince | from __future__ import annotations
import tempfile
import numpy as np
import pytest
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
import prince
from tests import load_df_from_R
class TestFAMD:
_row_name = "row"
_col_name = "col"
def _prepare(self... | P["% of variance (cumulative)"]) | assert_* | func_call | tests/test_famd.py | test_eigenvalues | TestFAMD | 73 | null |
MaxHalford/prince | from __future__ import annotations
import unittest
import numpy as np
import pandas as pd
import prince
class TestGPA(unittest.TestCase):
def setUp(self):
# Create a list of 2-D circles with different locations and rotations
n_shapes = 4
n_points = 12
n_dims = 2
shape_si... | ValueError) | self.assertRaises | variable | tests/test_gpa.py | test_fit_bad_init | TestGPA | 47 | null |
MaxHalford/prince | from __future__ import annotations
import unittest
import numpy as np
import pandas as pd
import prince
class TestGPA(unittest.TestCase):
def setUp(self):
# Create a list of 2-D circles with different locations and rotations
n_shapes = 4
n_points = 12
n_dims = 2
shape_si... | prince.GPA) | self.assertIsInstance | complex_expr | tests/test_gpa.py | test_fit | TestGPA | 34 | null |
MaxHalford/prince | from __future__ import annotations
import tempfile
import numpy as np
import pandas as pd
import pytest
from rpy2.robjects import r as R
import prince
from tests import load_df_from_R
from tests.test_ca import TestCA as _TestCA
class TestMCA(_TestCA):
_row_name = "ind"
_col_name = "var"
def _prepare(se... | P.loc[F.index]) | assert_* | complex_expr | tests/test_mca.py | test_col_cos2 | TestMCA | 83 | null |
MaxHalford/prince | from __future__ import annotations
import tempfile
import numpy as np
import pandas as pd
import pytest
from rpy2.robjects import r as R
import prince
from tests import load_df_from_R
from tests.test_ca import TestCA as _TestCA
class TestMCA(_TestCA):
_row_name = "ind"
_col_name = "var"
def _prepare(se... | P.abs().loc[F.index]) | assert_* | func_call | tests/test_mca.py | test_col_coords | TestMCA | 70 | null |
MaxHalford/prince | from __future__ import annotations
import math
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import numpy2ri
from sklearn import decomposition, pipeline, preprocessing
import prince
from t... | self.sk_pca[-1].explained_variance_ratio_ * 100) | assert_* | complex_expr | tests/test_pca.py | test_eigenvalues | TestPCA | 137 | null |
MaxHalford/prince | from __future__ import annotations
import unittest
import numpy as np
import pandas as pd
import prince
class TestGPA(unittest.TestCase):
def setUp(self):
# Create a list of 2-D circles with different locations and rotations
n_shapes = 4
n_points = 12
n_dims = 2
shape_si... | shapes_copy) | assert_* | variable | tests/test_gpa.py | test_copy | TestGPA | 82 | null |
MaxHalford/prince | from __future__ import annotations
import math
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import numpy2ri
from sklearn import decomposition, pipeline, preprocessing
import prince
from t... | P["% of variance"]) | assert_* | complex_expr | tests/test_pca.py | test_eigenvalues | TestPCA | 128 | null |
MaxHalford/prince | from __future__ import annotations
import math
import tempfile
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
from scipy import sparse
import prince
from tests import load_df_... | P * 100) | assert_* | complex_expr | tests/test_ca.py | test_row_contrib | TestCA | 113 | null |
MaxHalford/prince | from __future__ import annotations
import tempfile
import numpy as np
import pytest
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
import prince
from tests import load_df_from_R
class TestFAMD:
_row_name = "row"
_col_name = "col"
def _prepare(self... | ["is_organic", "style"] | assert | collection | tests/test_famd.py | test_cat_cols | TestFAMD | 66 | null |
MaxHalford/prince | from __future__ import annotations
import math
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import numpy2ri
from sklearn import decomposition, pipeline, preprocessing
import prince
from t... | P * 100) | assert_* | complex_expr | tests/test_pca.py | test_row_contrib | TestPCA | 165 | null |
MaxHalford/prince | from __future__ import annotations
import math
import tempfile
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
import prince
from tests import load_df_from_R
class TestMFA:
... | P["% of variance"]) | assert_* | complex_expr | tests/test_mfa.py | test_eigenvalues | TestMFA | 76 | null |
MaxHalford/prince | from __future__ import annotations
import math
import tempfile
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
from scipy import sparse
import prince
from tests import load_df_... | P["eigenvalue"]) | assert_* | complex_expr | tests/test_ca.py | test_eigenvalues | TestCA | 94 | null |
MaxHalford/prince | from __future__ import annotations
import math
import tempfile
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
from scipy import sparse
import prince
from tests import load_df_... | P.abs()) | assert_* | func_call | tests/test_ca.py | test_row_coords | TestCA | 108 | null |
MaxHalford/prince | from __future__ import annotations
import math
import tempfile
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
from scipy import sparse
import prince
from tests import load_df_... | P) | assert_* | variable | tests/test_ca.py | test_row_cosine_similarities | TestCA | 120 | null |
MaxHalford/prince | from __future__ import annotations
import math
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import numpy2ri
from sklearn import decomposition, pipeline, preprocessing
import prince
from t... | P["eigenvalue"]) | assert_* | complex_expr | tests/test_pca.py | test_eigenvalues | TestPCA | 127 | null |
MaxHalford/prince | from __future__ import annotations
import math
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import numpy2ri
from sklearn import decomposition, pipeline, preprocessing
import prince
from t... | P) | assert_* | variable | tests/test_pca.py | test_row_cosine_similarities | TestPCA | 160 | null |
MaxHalford/prince | from __future__ import annotations
import math
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import numpy2ri
from sklearn import decomposition, pipeline, preprocessing
import prince
from t... | P.abs()) | assert_* | func_call | tests/test_pca.py | test_row_coords | TestPCA | 149 | null |
MaxHalford/prince | from __future__ import annotations
import unittest
import numpy as np
import pandas as pd
import prince
class TestGPA(unittest.TestCase):
def setUp(self):
# Create a list of 2-D circles with different locations and rotations
n_shapes = 4
n_points = 12
n_dims = 2
shape_si... | aligned_shapes[1:]) | assert_* | complex_expr | tests/test_gpa.py | test_fit_transform_equal | TestGPA | 68 | null |
MaxHalford/prince | from __future__ import annotations
import math
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import numpy2ri
from sklearn import decomposition, pipeline, preprocessing
import prince
from t... | P["% of variance (cumulative)"]) | assert_* | func_call | tests/test_pca.py | test_eigenvalues | TestPCA | 129 | null |
MaxHalford/prince | from __future__ import annotations
import unittest
import numpy as np
import pandas as pd
import prince
class TestGPA(unittest.TestCase):
def setUp(self):
# Create a list of 2-D circles with different locations and rotations
n_shapes = 4
n_points = 12
n_dims = 2
shape_si... | aligned_shapes) | assert_* | variable | tests/test_gpa.py | test_fit_transform_single | TestGPA | 75 | null |
MaxHalford/prince | from __future__ import annotations
import tempfile
import numpy as np
import pytest
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
import prince
from tests import load_df_from_R
class TestFAMD:
_row_name = "row"
_col_name = "col"
def _prepare(self... | P["% of variance"]) | assert_* | complex_expr | tests/test_famd.py | test_eigenvalues | TestFAMD | 72 | null |
MaxHalford/prince | from __future__ import annotations
import math
import tempfile
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
from scipy import sparse
import prince
from tests import load_df_... | P["% of variance (cumulative)"]) | assert_* | func_call | tests/test_ca.py | test_eigenvalues | TestCA | 96 | null |
MaxHalford/prince | from __future__ import annotations
import tempfile
import numpy as np
import pytest
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
import prince
from tests import load_df_from_R
class TestFAMD:
_row_name = "row"
_col_name = "col"
def _prepare(self... | P["eigenvalue"]) | assert_* | complex_expr | tests/test_famd.py | test_eigenvalues | TestFAMD | 71 | null |
MaxHalford/prince | from __future__ import annotations
import numpy as np
import pytest
import rpy2.robjects as robjects
from rpy2.robjects import numpy2ri
from prince import svd
from tests import load_df_from_R
class TestSVD:
def _prepare(self, n_components, are_rows_weighted, are_columns_weighted):
self.n_components = n_... | (100, self.n_components) | assert | collection | tests/test_svd.py | test_U | TestSVD | 64 | null |
MaxHalford/prince | from __future__ import annotations
import tempfile
import numpy as np
import pytest
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
import prince
from tests import load_df_from_R
class TestFAMD:
_row_name = "row"
_col_name = "col"
def _prepare(self... | P.abs()) | assert_* | func_call | tests/test_famd.py | test_row_coords | TestFAMD | 82 | null |
MaxHalford/prince | from __future__ import annotations
import math
import tempfile
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
import prince
from tests import load_df_from_R
class TestMFA:
... | P["% of variance (cumulative)"]) | assert_* | func_call | tests/test_mfa.py | test_eigenvalues | TestMFA | 77 | null |
MaxHalford/prince | from __future__ import annotations
import math
import tempfile
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import r as R
import prince
from tests import load_df_from_R
class TestMFA:
... | P["eigenvalue"]) | assert_* | complex_expr | tests/test_mfa.py | test_eigenvalues | TestMFA | 75 | null |
MaxHalford/prince | from __future__ import annotations
import numpy as np
import pytest
import rpy2.robjects as robjects
from rpy2.robjects import numpy2ri
from prince import svd
from tests import load_df_from_R
class TestSVD:
def _prepare(self, n_components, are_rows_weighted, are_columns_weighted):
self.n_components = n_... | (self.n_components,) | assert | collection | tests/test_svd.py | test_s | TestSVD | 71 | null |
MaxHalford/prince | from __future__ import annotations
import numpy as np
import pytest
import rpy2.robjects as robjects
from rpy2.robjects import numpy2ri
from prince import svd
from tests import load_df_from_R
class TestSVD:
def _prepare(self, n_components, are_rows_weighted, are_columns_weighted):
self.n_components = n_... | np.abs(P)) | assert_* | func_call | tests/test_svd.py | test_U | TestSVD | 68 | null |
MaxHalford/prince | from __future__ import annotations
import numpy as np
import pytest
import rpy2.robjects as robjects
from rpy2.robjects import numpy2ri
from prince import svd
from tests import load_df_from_R
class TestSVD:
def _prepare(self, n_components, are_rows_weighted, are_columns_weighted):
self.n_components = n_... | (self.n_components, 10) | assert | collection | tests/test_svd.py | test_V | TestSVD | 78 | null |
MaxHalford/prince | from __future__ import annotations
import math
import numpy as np
import pandas as pd
import pytest
import rpy2.robjects as robjects
import sklearn.utils.estimator_checks
import sklearn.utils.validation
from rpy2.robjects import numpy2ri
from sklearn import decomposition, pipeline, preprocessing
import prince
from t... | S) | assert_* | variable | tests/test_pca.py | test_eigenvalues | TestPCA | 136 | null |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from fvalues import FValue
from langchain import PromptTemplate
from langchain.llms import OpenAI
one_input_prompt = PromptTemplate(
input_variables=["adjective"], template="Tell me a {adjective} joke."
)
prompt = o... | ( "Tell me a ", FValue(source="adjective", value="funny", formatted="funny"), " joke.", ) | assert | collection | tests/prompts/langchain_getting_started/test_one_input.py | test_prompt | 24 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import pytest
import vcr_langchain as vcr
from langchain import LLMMathChain, SerpAPIWrapper, SQLDatabase
from langchain.agents import AgentType, Tool, initialize_agent
from langchain.chat_models import ChatOpenAI
from langchain_experimental.sql im... | ValueError) | pytest.raises | variable | tests/agents/test_openai_functions.py | test_llm_usage_succeeds | 61 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
from fvalues import FValue
from langchain import PromptTemplate
def test_partial_f():
partial = PromptTemplate.from_template("hello {foo} world {bar}").partial(foo="3")
final = partial.format(bar="7")
assert final == "hello 3 world 7"
assert fin... | ( "hello ", FValue(source="foo", value="3", formatted="3"), " world ", FValue(source="bar", value="7", formatted="7"), ) | assert | collection | tests/prompts/test_prompt_template_f.py | test_partial_f | 80 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain.chains import LLMCheckerChain
from langchain.llms import OpenAI
async def checker_chain_demo():
llm = OpenAI(temperature=0.7)
text = "What type of mammal lays the biggest eggs?"
checker_chain ... | result | assert | variable | tests/chains/langchain_how_to/utility_chains/llm_checker_chain.py | test_llm_usage_succeeds | 26 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import pytest
from langchain.agents import AgentType, initialize_agent, load_tools
from langchain.llms import OpenAI
llm = OpenAI(temperature=0)
tools = load_tools(["serpapi", "llm-math"], llm=llm)
agent = initialize_agent(
tools, llm, agent=A... | result.strip() | assert | func_call | tests/agents/test_langchain_without_vcr.py | test_llm_usage_succeeds | 37 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain import FewShotPromptTemplate, PromptTemplate
from langchain.llms import OpenAI
examples = [
{"word": "happy", "antonym": "sad"},
{"word": "tall", "antonym": "short"},
]
example_formatter_template... | """ Give the antonym of every input Word: happy Antonym: sad Word: tall Antonym: short Word: big Antonym: """.lstrip() | assert | string_literal | tests/prompts/langchain_getting_started/test_few_shot.py | test_prompt | 45 | null | |
amosjyng/langchain-visualizer | import subprocess
def test_start_with_args():
result = subprocess.run(
"python3 tests/dummy_viz.py asdf",
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
assert "error: unrecognized arguments" not in | result.stderr.decode() | assert | func_call | tests/test_cli_args.py | test_start_with_args | 13 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
from fvalues import FValue
from langchain import PromptTemplate
def test_add_f():
f1 = PromptTemplate(template="hello {foo}", input_variables=["foo"]).format(foo="3")
f2 = PromptTemplate(template="world {bar}", input_variables=["bar"]).format(bar="7")
... | ( FValue(source='f1 + " "', value="hello 3 ", formatted="hello 3 "), FValue(source="f2", value="world 7", formatted="world 7"), ) | assert | collection | tests/prompts/test_prompt_template_f.py | test_add_f | 17 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
from langchain.llms import OpenAI
from tests.sotu import load_sotu
docsearch = load_sotu()
async def map_rerank_demo():
query = "What did the... | result["output_text"] | assert | complex_expr | tests/chains/langchain_how_to/combine_documents_chains/test_map_rerank.py | test_map_rerank_succeeds | 36 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain import PromptTemplate
from langchain.chains import ConversationChain, LLMChain
from langchain.chains.router import MultiPromptChain
from langchain.chains.router.embedding_router import EmbeddingRouterChain... | results[-1].lower() | assert | func_call | tests/chains/foundational/test_router_embedding.py | test_llm_usage_succeeds | 99 | null | |
amosjyng/langchain-visualizer | import subprocess
def test_start_with_args():
result = subprocess.run(
"python3 tests/dummy_viz.py asdf",
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
assert "error: unrecognized arguments" not in result.stderr.decode()
assert "Opening trace in browser"... | result.stdout.decode() | assert | func_call | tests/test_cli_args.py | test_start_with_args | 14 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
from fvalues import FValue
from langchain import PromptTemplate
def test_strip():
space = " "
s = PromptTemplate(
template=" {space} hello {space} ", input_variables=["space"]
).format(space=space)
assert s == " hello "
assert s.p... | "hello " | assert | string_literal | tests/prompts/test_prompt_template_f.py | test_strip | 58 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain import SerpAPIWrapper
from langchain.agents import AgentType, Tool, initialize_agent
from langchain.chat_models import ChatOpenAI
async def openai_multifunctions_demo():
llm = ChatOpenAI(temperature=0... | result | assert | variable | tests/agents/test_openai_multifunctions.py | test_llm_usage_succeeds | 45 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from fvalues import FValue
from langchain import PromptTemplate
from langchain.llms import OpenAI
multiple_input_prompt = PromptTemplate(
input_variables=["adjective", "content"],
template="Tell me a {adjective}... | ( "Tell me a ", FValue(source="adjective", value="funny", formatted="funny"), " joke about ", FValue(source="content", value="chickens", formatted="chickens"), ".", ) | assert | collection | tests/prompts/langchain_getting_started/test_multiple_inputs.py | test_prompt | 25 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
from fvalues import FValue
from langchain import FewShotPromptTemplate, PromptTemplate
def test_few_shot_f():
examples = [
{"word": "happy", "antonym": "sad"},
{"word": "tall", "antonym": "short"},
# Should be able to handle extra key... | "Give the antonym of every input: " "w=happy,a=sad w=tall,a=short w=better,a=worse w=big,a=" | assert | string_literal | tests/prompts/test_few_shot_prompt_template_f.py | test_few_shot_f | 30 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
from fvalues import FValue
from langchain import PromptTemplate
def test_add_f():
f1 = PromptTemplate(template="hello {foo}", input_variables=["foo"]).format(foo="3")
f2 = PromptTemplate(template="world {bar}", input_variables=["bar"]).format(bar="7")
... | ( "hello ", FValue(source="foo", value="3", formatted="3"), " ", "world ", FValue(source="bar", value="7", formatted="7"), ) | assert | collection | tests/prompts/test_prompt_template_f.py | test_add_f | 21 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import vcr_langchain as vcr
from langchain import PromptTemplate
from langchain.llms import OpenAI
@vcr.use_cassette()
async def test_partial_with_strings():
agent = OpenAI(model_name="text-ada-001", temperature=0)
prompt = PromptTemplate.from_template("... | "Why did the chicken cross the road?" | assert | string_literal | tests/prompts/partial/test_with_strings.py | test_partial_with_strings | 17 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
from fvalues import FValue
from langchain import PromptTemplate
def test_add_f():
f1 = PromptTemplate(template="hello {foo}", input_variables=["foo"]).format(foo="3")
f2 = PromptTemplate(template="world {bar}", input_variables=["bar"]).format(bar="7")
... | "hello 3 world 7" | assert | string_literal | tests/prompts/test_prompt_template_f.py | test_add_f | 16 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain.llms import OpenAI
llm = OpenAI(model="text-davinci-003", n=2, best_of=2, temperature=1)
async def getting_started_demo():
return llm.generate(["Tell me a joke", "Tell me a poem"] * 2)
def test_llm_... | 2 | assert | numeric_literal | tests/llms/test_langchain_getting_started.py | test_llm_usage_succeeds | 28 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain import PromptTemplate
from langchain.llms import OpenAI
no_input_prompt = PromptTemplate(input_variables=[], template="Tell me a joke.")
prompt = no_input_prompt.format()
def test_prompt():
assert p... | ("Tell me a joke.",) | assert | collection | tests/prompts/langchain_getting_started/test_no_inputs.py | test_prompt | 21 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain.chains import LLMChain
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
async def async_generate(chain: LLMChain):
resp = await chain.arun(product="toothpaste")
retur... | 5 | assert | numeric_literal | tests/chains/langchain_how_to/test_async.py | test_llm_usage_succeeds | 40 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
from langchain.llms import OpenAI
from tests.sotu import load_sotu
docsearch = load_sotu()
async def refine_demo():
query = "What did the pre... | result["output_text"] | assert | complex_expr | tests/chains/langchain_how_to/combine_documents_chains/test_refine.py | test_refine_succeeds | 33 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
from fvalues import FValue
from langchain import PromptTemplate
def test_strip():
space = " "
s = PromptTemplate(
template=" {space} hello {space} ", input_variables=["space"]
).format(space=space)
assert s == " hello "
assert s.p... | "hello" | assert | string_literal | tests/prompts/test_prompt_template_f.py | test_strip | 56 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
from langchain.llms import OpenAI
from tiktoken_ext.openai_public import p50k_base
from tests.sotu import load_sotu
docsearch = load_sotu()
async... | result["output_text"] | assert | complex_expr | tests/chains/langchain_how_to/combine_documents_chains/test_mapreduce.py | test_mapreduce_succeeds | 37 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
from fvalues import FValue
from langchain import PromptTemplate
def test_still_node_from_eval():
# unlike the original fvalues, PromptTemplate should work regardless
s = eval(
'PromptTemplate(template="hello {foo}", '
'input_variables=["f... | "hello world" | assert | string_literal | tests/prompts/test_prompt_template_f.py | test_still_node_from_eval | 36 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain.chains import ConversationChain, LLMChain
from langchain.chains.router import MultiPromptChain
from langchain.chains.router.llm_router import LLMRouterChain, RouterOutputParser
from langchain.chains.router... | 3 | assert | numeric_literal | tests/chains/foundational/test_router.py | test_llm_usage_succeeds | 97 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain import PromptTemplate
from langchain.chains import LLMChain
from langchain.llms import OpenAI
llm = OpenAI(temperature=0)
prompt = PromptTemplate(
input_variables=["product"],
template="What is a ... | "Socktastic!" | assert | string_literal | tests/chains/langchain_getting_started/test_llm_chain.py | test_llm_usage_succeeds | 33 | null | |
amosjyng/langchain-visualizer | import langchain_visualizer # isort:skip # noqa: F401
import asyncio
import vcr_langchain as vcr
from langchain.llms import OpenAI
llm = OpenAI(model="text-davinci-003", n=2, best_of=2, temperature=1)
async def getting_started_demo():
return llm.generate(["Tell me a joke", "Tell me a poem"] * 2)
def test_llm_... | 4 | assert | numeric_literal | tests/llms/test_langchain_getting_started.py | test_llm_usage_succeeds | 27 | null | |
Forethought-Technologies/AutoChain | from autochain.agent.message import MessageType
from autochain.memory.long_term_memory import LongTermMemory
from autochain.tools.internal_search.chromadb_tool import ChromaDoc, ChromaDBSearch
from autochain.tools.internal_search.pinecone_tool import PineconeSearch, PineconeDoc
from autochain.tools.internal_search.lanc... | "v2" | assert | string_literal | tests/memory/test_long_term_memory.py | test_long_term_kv_memory_chromadb | 18 | null | |
Forethought-Technologies/AutoChain | from autochain.agent.message import MessageType
from autochain.memory.buffer_memory import BufferMemory
def test_buffer_kv_memory():
memory = BufferMemory()
memory.save_memory(key="k", value="v")
value = memory.load_memory(key="k")
assert value == | "v" | assert | string_literal | tests/memory/test_buffer_memory.py | test_buffer_kv_memory | 9 | null | |
Forethought-Technologies/AutoChain | from autochain.tools.internal_search.chromadb_tool import ChromaDBSearch, ChromaDoc
def test_chromadb_tool_run():
d1 = ChromaDoc("This is document1", metadata={"source": "notion"})
d2 = ChromaDoc("This is document2", metadata={"source": "google-docs"})
t = ChromaDBSearch(
docs=[d1, d2], name="int... | "Doc 0: This is document1\nDoc 1: This is document2" | assert | string_literal | tests/tools/test_chromadb_tool.py | test_chromadb_tool_run | 13 | null | |
Forethought-Technologies/AutoChain | import pytest
from autochain.tools.base import Tool
def sample_tool_func(k, *arg, **kwargs):
return f"run with {k}"
def test_run_tool():
tool = Tool(
func=sample_tool_func,
description="""This is just a dummy tool""",
)
output = tool.run("test")
assert output == | "run with test" | assert | string_literal | tests/tools/test_base_tool.py | test_run_tool | 17 | null | |
Forethought-Technologies/AutoChain | from unittest import mock
import pytest
from autochain.agent.message import (
ChatMessageHistory,
MessageType,
)
from autochain.agent.openai_functions_agent.openai_functions_agent import (
OpenAIFunctionsAgent,
)
from autochain.agent.structs import AgentAction, AgentFinish
from autochain.models.chat_openai... | "get_current_weather" | assert | string_literal | tests/agent/test_openai_functions_agent.py | test_function_calling_plan | 97 | null | |
Forethought-Technologies/AutoChain | import os
from unittest import mock
import pytest
from autochain.tools.google_search.util import GoogleSearchAPIWrapper
def google_search_fixture():
with mock.patch(
"autochain.tools.google_search.util.GoogleSearchAPIWrapper._google_search_results",
return_value=[{"snippet": "Barack Hussein Obama... | output | assert | variable | tests/tools/test_google_search.py | test_google_search | 24 | null | |
Forethought-Technologies/AutoChain | import json
import os
from unittest import mock
import pytest
from autochain.agent.conversational_agent.conversational_agent import (
ConversationalAgent,
)
from autochain.agent.message import (
ChatMessageHistory,
MessageType,
)
from autochain.agent.structs import AgentFinish
from autochain.models.chat_... | None | assert | none_literal | tests/agent/test_conversational_agent.py | test_should_answer_prompt | 102 | null | |
Forethought-Technologies/AutoChain | import pickle
from unittest.mock import MagicMock
from autochain.agent.message import AIMessage, MessageType, UserMessage
from autochain.memory.redis_memory import RedisMemory
from redis.client import Redis
def test_redis_conversation_memory():
mock_redis = MagicMock(spec=Redis)
user_query = "user query"
... | "" | assert | string_literal | tests/memory/test_redis_memory.py | test_redis_conversation_memory | 49 | null | |
Forethought-Technologies/AutoChain | import pickle
from unittest.mock import MagicMock
from autochain.agent.message import AIMessage, MessageType, UserMessage
from autochain.memory.redis_memory import RedisMemory
from redis.client import Redis
def test_redis_kv_memory():
mock_redis = MagicMock(spec=Redis)
pickled = pickle.dumps("v")
mock_red... | None | assert | none_literal | tests/memory/test_redis_memory.py | test_redis_kv_memory | 24 | null | |
Forethought-Technologies/AutoChain | from autochain.tools.internal_search.pinecone_tool import PineconeSearch, PineconeDoc
from test_utils.pinecone_mocks import (
DummyEncoder,
pinecone_index_fixture,
)
def test_pinecone_search(pinecone_index_fixture):
docs = [PineconeDoc(doc="test_document", id="A")]
pinecone_search = PineconeSearch(
... | [ -0.025949304923415184, -0.012664584442973137, 0.017791053280234337, ] | assert | collection | tests/tools/test_pinecone_tool.py | test_pinecone_search | 17 | null | |
Forethought-Technologies/AutoChain | from autochain.agent.message import MessageType
from autochain.memory.long_term_memory import LongTermMemory
from autochain.tools.internal_search.chromadb_tool import ChromaDoc, ChromaDBSearch
from autochain.tools.internal_search.pinecone_tool import PineconeSearch, PineconeDoc
from autochain.tools.internal_search.lanc... | "Doc 0: This is document1" | assert | string_literal | tests/memory/test_long_term_memory.py | test_long_term_memory | 47 | null | |
Forethought-Technologies/AutoChain | from unittest import mock
import pytest
from autochain.agent.message import (
ChatMessageHistory,
MessageType,
)
from autochain.agent.openai_functions_agent.openai_functions_agent import (
OpenAIFunctionsAgent,
)
from autochain.agent.structs import AgentAction, AgentFinish
from autochain.models.chat_openai... | False | assert | bool_literal | tests/agent/test_openai_functions_agent.py | test_estimate_confidence | 129 | null | |
Forethought-Technologies/AutoChain | import pytest
from autochain.tools.base import Tool
def sample_tool_func(k, *arg, **kwargs):
return f"run with {k}"
def test_arg_description():
valid_arg_description = {"k": "key of the arg"}
invalid_arg_description = {"not_k": "key of the arg"}
_ = Tool(
func=sample_tool_func,
desc... | ValueError) | pytest.raises | variable | tests/tools/test_base_tool.py | test_arg_description | 42 | null | |
Forethought-Technologies/AutoChain | import os
from unittest import mock
import pytest
from autochain.tools.base import Tool
from autochain.agent.message import UserMessage
from autochain.models.base import LLMResult
from autochain.models.chat_openai import ChatOpenAI, convert_tool_to_dict
def sample_tool_func_no_type(k, *arg, **kwargs):
return f"r... | { "name": "sample_tool_func_with_type_default", "description": "This is just a dummy tool with typing info", "parameters": { "type": "object", "properties": {"k": {"type": "int"}, "d": {"type": "int"}}, "required": ["k"], }, } | assert | collection | tests/models/test_chat_openai.py | test_convert_tool_to_dict | 87 | null | |
Forethought-Technologies/AutoChain | from autochain.agent.message import MessageType
from autochain.memory.buffer_memory import BufferMemory
def test_buffer_kv_memory():
memory = BufferMemory()
memory.save_memory(key="k", value="v")
value = memory.load_memory(key="k")
assert value == "v"
default_value = memory.load_memory(key="k2", d... | "v2" | assert | string_literal | tests/memory/test_buffer_memory.py | test_buffer_kv_memory | 12 | null | |
Forethought-Technologies/AutoChain | from autochain.agent.message import MessageType
from autochain.memory.buffer_memory import BufferMemory
def test_buffer_kv_memory():
memory = BufferMemory()
memory.save_memory(key="k", value="v")
value = memory.load_memory(key="k")
assert value == "v"
default_value = memory.load_memory(key="k2", d... | None | assert | none_literal | tests/memory/test_buffer_memory.py | test_buffer_kv_memory | 15 | null | |
Forethought-Technologies/AutoChain | from autochain.agent.message import MessageType
from autochain.memory.long_term_memory import LongTermMemory
from autochain.tools.internal_search.chromadb_tool import ChromaDoc, ChromaDBSearch
from autochain.tools.internal_search.pinecone_tool import PineconeSearch, PineconeDoc
from autochain.tools.internal_search.lanc... | "v" | assert | string_literal | tests/memory/test_long_term_memory.py | test_long_term_kv_memory_chromadb | 15 | null | |
Forethought-Technologies/AutoChain | from autochain.tools.simple_handoff.tool import HandOffToAgent
def test_simple_handoff() -> None:
handoff = HandOffToAgent()
msg = handoff.run()
assert handoff.handoff_msg == | msg | assert | variable | tests/tools/test_simple_handoff.py | test_simple_handoff | 7 | null | |
Forethought-Technologies/AutoChain | import pytest
from autochain.tools.base import Tool
def sample_tool_func(k, *arg, **kwargs):
return f"run with {k}"
def test_tool_name_override():
new_test_name = "new_name"
tool = Tool(
name=new_test_name,
func=sample_tool_func,
description="""This is just a dummy tool""",
)
... | new_test_name | assert | variable | tests/tools/test_base_tool.py | test_tool_name_override | 28 | null | |
Forethought-Technologies/AutoChain | import os
from unittest import mock
import pytest
from autochain.tools.base import Tool
from autochain.agent.message import UserMessage
from autochain.models.base import LLMResult
from autochain.models.chat_openai import ChatOpenAI, convert_tool_to_dict
def sample_tool_func_no_type(k, *arg, **kwargs):
return f"r... | "generated message" | assert | string_literal | tests/models/test_chat_openai.py | test_chat_completion | 44 | null | |
Forethought-Technologies/AutoChain | from autochain.tools.internal_search.pinecone_tool import PineconeSearch, PineconeDoc
from test_utils.pinecone_mocks import (
DummyEncoder,
pinecone_index_fixture,
)
def test_pinecone_search(pinecone_index_fixture):
docs = [PineconeDoc(doc="test_document", id="A")]
pinecone_search = PineconeSearch(
... | "Doc 0: test_document" | assert | string_literal | tests/tools/test_pinecone_tool.py | test_pinecone_search | 22 | null | |
Forethought-Technologies/AutoChain | from autochain.tools.internal_search.lancedb_tool import LanceDBDoc, LanceDBSeach
from test_utils import DummyEncoder
def test_lancedb_search():
docs = [LanceDBDoc(doc="test_document", id="A")]
lancedb_search = LanceDBSeach(
uri="lancedb",
description="internal search with lancedb",
do... | [ -0.025949304923415184, -0.012664584442973137, 0.017791053280234337, ] | assert | collection | tests/tools/test_lancedb_tool.py | test_lancedb_search | 14 | null | |
Forethought-Technologies/AutoChain | from autochain.tools.internal_search.lancedb_tool import LanceDBDoc, LanceDBSeach
from test_utils import DummyEncoder
def test_lancedb_search():
docs = [LanceDBDoc(doc="test_document", id="A")]
lancedb_search = LanceDBSeach(
uri="lancedb",
description="internal search with lancedb",
do... | "Doc 0: test_document" | assert | string_literal | tests/tools/test_lancedb_tool.py | test_lancedb_search | 19 | null | |
Forethought-Technologies/AutoChain | import pickle
from unittest.mock import MagicMock
from autochain.agent.message import AIMessage, MessageType, UserMessage
from autochain.memory.redis_memory import RedisMemory
from redis.client import Redis
def test_redis_kv_memory():
mock_redis = MagicMock(spec=Redis)
pickled = pickle.dumps("v")
mock_red... | "v2" | assert | string_literal | tests/memory/test_redis_memory.py | test_redis_kv_memory | 21 | null | |
Forethought-Technologies/AutoChain | import os
from unittest import mock
import pytest
from autochain.tools.base import Tool
from autochain.agent.message import UserMessage
from autochain.models.base import LLMResult
from autochain.models.chat_openai import ChatOpenAI, convert_tool_to_dict
def sample_tool_func_no_type(k, *arg, **kwargs):
return f"r... | { "name": "sample_tool_func_no_type", "description": "This is just a " "dummy tool without typing info", "parameters": { "type": "object", "properties": {"k": {"type": "string"}}, "required": ["k"], }, } | assert | collection | tests/models/test_chat_openai.py | test_convert_tool_to_dict | 55 | null | |
Forethought-Technologies/AutoChain | import pickle
from unittest.mock import MagicMock
from autochain.agent.message import AIMessage, MessageType, UserMessage
from autochain.memory.redis_memory import RedisMemory
from redis.client import Redis
def test_redis_kv_memory():
mock_redis = MagicMock(spec=Redis)
pickled = pickle.dumps("v")
mock_red... | "v" | assert | string_literal | tests/memory/test_redis_memory.py | test_redis_kv_memory | 18 | null | |
Forethought-Technologies/AutoChain | import os
from unittest import mock
import pytest
from autochain.tools.base import Tool
from autochain.agent.message import UserMessage
from autochain.models.base import LLMResult
from autochain.models.chat_openai import ChatOpenAI, convert_tool_to_dict
def sample_tool_func_no_type(k, *arg, **kwargs):
return f"r... | { "name": "sample_tool_func_with_type", "description": "This is just a dummy tool with typing info", "parameters": { "type": "object", "properties": {"k": {"type": "int", "description": "key of the arg"}}, "required": ["k"], }, } | assert | collection | tests/models/test_chat_openai.py | test_convert_tool_to_dict | 104 | null | |
Forethought-Technologies/AutoChain | from autochain.agent.message import MessageType
from autochain.memory.buffer_memory import BufferMemory
def test_buffer_conversation_memory():
memory = BufferMemory()
memory.save_conversation("user query", MessageType.UserMessage)
memory.save_conversation("response to user", MessageType.AIMessage)
con... | "User: user query\nAssistant: response to user\n" | assert | string_literal | tests/memory/test_buffer_memory.py | test_buffer_conversation_memory | 24 | null | |
Forethought-Technologies/AutoChain | from autochain.agent.message import MessageType
from autochain.memory.long_term_memory import LongTermMemory
from autochain.tools.internal_search.chromadb_tool import ChromaDoc, ChromaDBSearch
from autochain.tools.internal_search.pinecone_tool import PineconeSearch, PineconeDoc
from autochain.tools.internal_search.lanc... | None | assert | none_literal | tests/memory/test_long_term_memory.py | test_long_term_kv_memory_chromadb | 21 | null | |
Forethought-Technologies/AutoChain | import os
from unittest import mock
import pytest
from autochain.models.ada_embedding import OpenAIAdaEncoder
from autochain.models.base import EmbeddingResult
def ada_encoding_fixture():
with mock.patch(
"openai.Embedding.create",
return_value={
"object": "list",
"data": ... | [ -0.025949304923415184, -0.012664584442973137, 0.017791053280234337, ] | assert | collection | tests/models/test_openai_ada_encoder.py | test_ada_encoder | 45 | null | |
fennerm/flashfocus | from __future__ import annotations
import pytest
from flashfocus.compat import DisplayHandler, Window, get_workspace
from flashfocus.display import WMEvent, WMEventType
from flashfocus.errors import WMError
from tests.compat import change_focus, set_fullscreen, unset_fullscreen
from tests.helpers import new_window_ses... | WMError) | pytest.raises | variable | tests/test_compat.py | test_window_raises_wm_error_if_window_is_none | 13 | null | |
fennerm/flashfocus | from __future__ import annotations
from copy import deepcopy
import pytest
from pytest_lazyfixture import lazy_fixture
from flashfocus.config import (
construct_config_error_msg,
dehyphen,
get_default_config_file,
hierarchical_merge,
load_config,
load_merged_config,
merge_config_sources,
... | None | assert | none_literal | tests/test_config.py | test_if_x11_wayland_rules_are_dropped_during_validation | 224 | null | |
fennerm/flashfocus | from __future__ import annotations
from copy import deepcopy
import pytest
from pytest_lazyfixture import lazy_fixture
from flashfocus.config import (
construct_config_error_msg,
dehyphen,
get_default_config_file,
hierarchical_merge,
load_config,
load_merged_config,
merge_config_sources,
... | [True, False] | assert | collection | tests/test_config.py | check_validated_config | 85 | null | |
fennerm/flashfocus | from __future__ import annotations
from copy import deepcopy
import pytest
from pytest_lazyfixture import lazy_fixture
from flashfocus.config import (
construct_config_error_msg,
dehyphen,
get_default_config_file,
hierarchical_merge,
load_config,
load_merged_config,
merge_config_sources,
... | expected | assert | variable | tests/test_config.py | test_dehyphen | 172 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.