Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linter (will break as we have style issues) #38

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint
on: push
jobs:
flake8_py3:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v1
- name: Checkout PyTorch
uses: actions/checkout@master
- name: Install flake8
run: pip install flake8 wemake-python-styleguide
- name: Run flake8
uses: suo/flake8-github-action@releases/v1
with:
checkName: 'flake8_py3' # NOTE: this needs to be the same as the job name
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
File renamed without changes.
44 changes: 24 additions & 20 deletions examples/agents/biochemist.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
import os
from log10.anthropic import Anthropic
from log10.llm import NoopLLM
from log10.agents.camel import camel_agent
"""Example of a biochemist agent using the camel agent framework."""

import anthropic
import openai
from dotenv import load_dotenv

from log10.openai import OpenAI
from log10.agents.camel import camel_agent
from log10.anthropic import Anthropic
from log10.llm import NoopLLM
from log10.load import log10
from log10.openai import OpenAI

load_dotenv()

# Select one of OpenAI or Anthropic models
# model = "noop"
model = "gpt-3.5-turbo-16k"
# model = "claude-1"
# Select one of OpenAI or Anthropic models with "claude-1" or "gpt-3.5-turbo"
model = 'gpt-3.5-turbo-16k'
max_turns = 30

llm = None
summary_model = None
if "claude" in model:
import anthropic
if 'claude' in model:
log10(anthropic)
summary_model = "claude-1-100k"
llm = Anthropic({"model": model})
elif model == "noop":
summary_model = 'claude-1-100k'
llm = Anthropic({'model': model})
elif model == 'noop':
summary_model = model
llm = NoopLLM()
else:
import openai
log10(openai)
summary_model = "gpt-3.5-turbo-16k"
llm = OpenAI({"model": model})
summary_model = 'gpt-3.5-turbo-16k'
llm = OpenAI({'model': model})

# example calls from playground (select 1)
camel_agent(
user_role="Poor PhD Student",
assistant_role="Experienced Computational Chemist",
task_prompt="Perform a molecular dynamics solution of a molecule: CN1CCC[C@H]1c2cccnc2. Design and conduct a 100 ns molecular dynamics simulation of the molecule CN1CCC[C@H]1c2cccnc2 in an explicit solvent environment using the CHARMM force field and analyze the conformational changes and hydrogen bonding patterns over time",
user_role='Poor PhD Student',
assistant_role='Experienced Computational Chemist',
task_prompt="""
Perform a molecular dynamics solution of a molecule: CN1CCC[C@H]1c2cccnc2.
Design and conduct a 100 ns molecular dynamics simulation of the molecule
CN1CCC[C@H]1c2cccnc2 in an explicit solvent environment using the CHARMM
force field and analyze the conformational changes and hydrogen bonding
patterns over time""",
summary_model=summary_model,
max_turns=max_turns,
llm=llm,
Expand Down
75 changes: 50 additions & 25 deletions examples/agents/code_optimizer.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,69 @@
import os
"""Code optimizer agent example."""
# flake8: noqa

import anthropic
import openai

from log10.agents.camel import camel_agent
from log10.anthropic import Anthropic
from log10.evals import compile
from log10.llm import NoopLLM
from log10.load import log10
from log10.evals import compile
from log10.agents.camel import camel_agent
from log10.openai import OpenAI
from log10.tools import code_extractor

# Select one of OpenAI or Anthropic models
model = "gpt-3.5-turbo-16k"
# model = "claude-1"
# model = "noop"
# Select one of OpenAI or Anthropic models with "claude-1" or "gpt-3.5-turbo"
model = 'gpt-3.5-turbo-16k'
max_turns = 10

llm = None
summary_model = None
extraction_model = None
if "claude" in model:
import anthropic
if 'claude' in model:
log10(anthropic)
summary_model = "claude-1-100k"
extraction_model = "claude-1-100k"
llm = Anthropic({"model": model})
elif model == "noop":
summary_model = 'claude-1-100k'
extraction_model = 'claude-1-100k'
llm = Anthropic({'model': model})
elif model == 'noop':
summary_model = model
extraction_model = model
llm = NoopLLM()
else:
import openai
log10(openai)
summary_model = "gpt-3.5-turbo-16k"
extraction_model = "gpt-4"
llm = OpenAI({"model": model})

summary_model = 'gpt-3.5-turbo-16k'
extraction_model = 'gpt-4'
llm = OpenAI({'model': model})

# example calls from playground (select 1)
user_messages, assistant_messages = camel_agent(
user_role="C developer",
assistant_role="Cybersecurity expert",
task_prompt='Correct the following code.\n\n#include <stdio.h>\n#include <string.h>\n\nint main() {\n char password[8];\n int granted = 0;\n\n printf("Enter password: ");\n scanf("%s", password);\n\n if (strcmp(password, "password") == 0) {\n granted = 1;\n }\n\n if (granted) {\n printf("Access granted.\\n");\n } else {\n printf("Access denied.\\n");\n }\n\n return 0;\n}',
user_role='C developer',
assistant_role='Cybersecurity expert',
# noqa: WPS323 WPS342
task_prompt="""
Correct the following code.

#include <stdio.h>
#include <string.h>

int main() {
char password[8];
int granted = 0;

printf("Enter password: ");
scanf("%s", password);
if (strcmp(password, "password") == 0) {
granted = 1;
}

if (granted) {
printf("Access granted.\\n");
} else {
printf("Access denied.\\n");
}

return 0;
}
""",
summary_model=summary_model,
max_turns=max_turns,
llm=llm,
Expand All @@ -47,13 +72,13 @@
full_response = assistant_messages[-1].content

# Next extract just the C code
code = code_extractor(full_response, "C", extraction_model, llm=llm)
print(f"Extracted code\n###\n{code}")
code = code_extractor(full_response, 'C', extraction_model, llm=llm)
print(f'Extracted code\n###\n{code}')

# Evaluate if the code compiles
result = compile(code)
if result is True:
print("Compilation successful")
print('Compilation successful')
else:
print("Compilation failed with error:")
print('Compilation failed with error:')
print(result[1])
38 changes: 19 additions & 19 deletions examples/agents/coder.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import os
"""Agent that can code in Python and trade stocks."""

import anthropic
import openai
from dotenv import load_dotenv

from log10.agents.camel import camel_agent
from log10.anthropic import Anthropic
from log10.llm import NoopLLM
from log10.load import log10
from log10.agents.camel import camel_agent
from dotenv import load_dotenv

from log10.openai import OpenAI

load_dotenv()

# Select one of OpenAI or Anthropic models
model = "gpt-3.5-turbo-16k"
# model = "claude-1"
# model = "noop"

# Select one of OpenAI or Anthropic models with "claude-1" or "gpt-3.5-turbo"
model = 'gpt-3.5-turbo-16k'
max_turns = 30

llm = None
summary_model = None
if "claude" in model:
import anthropic
if 'claude' in model:
log10(anthropic)
summary_model = "claude-1-100k"
llm = Anthropic({"model": model})
elif model == "noop":
summary_model = 'claude-1-100k'
llm = Anthropic({'model': model})
elif model == 'noop':
summary_model = model
llm = NoopLLM()
else:
import openai
log10(openai)
summary_model = "gpt-3.5-turbo-16k"
llm = OpenAI({"model": model})
summary_model = 'gpt-3.5-turbo-16k'
llm = OpenAI({'model': model})

# example calls from playground (select 1)
camel_agent(
user_role="Stock Trader",
assistant_role="Python Programmer",
task_prompt="Develop a trading bot for the stock market",
user_role='Stock Trader',
assistant_role='Python Programmer',
task_prompt='Develop a trading bot for the stock market',
summary_model=summary_model,
max_turns=max_turns,
llm=llm,
Expand Down
29 changes: 16 additions & 13 deletions examples/agents/cybersecurity_expert.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
import os


from dotenv import load_dotenv

from log10.agents.camel import camel_agent
from log10.anthropic import Anthropic
from log10.llm import NoopLLM
from log10.load import log10
from log10.agents.camel import camel_agent
from dotenv import load_dotenv

from log10.openai import OpenAI

load_dotenv()

# Select one of OpenAI or Anthropic models
model = "gpt-3.5-turbo-16k"
model = 'gpt-3.5-turbo-16k'
# model = "claude-1"
# model = "noop"
max_turns = 30

llm = None
summary_model = None
if "claude" in model:
if 'claude' in model:
import anthropic

log10(anthropic)
summary_model = "claude-1-100k"
llm = Anthropic({"model": model})
elif model == "noop":
summary_model = 'claude-1-100k'
llm = Anthropic({'model': model})
elif model == 'noop':
summary_model = model
llm = NoopLLM()
else:
import openai

log10(openai)
summary_model = "gpt-3.5-turbo-16k"
llm = OpenAI({"model": model})
summary_model = 'gpt-3.5-turbo-16k'
llm = OpenAI({'model': model})

# example calls from playground (select 1)
camel_agent(
user_role="C developer",
assistant_role="Cybersecurity expert",
user_role='C developer',
assistant_role='Cybersecurity expert',
task_prompt='Correct the following code.\n\n#include <stdio.h>\n#include <string.h>\n\nint main() {\n char password[8];\n int granted = 0;\n\n printf("Enter password: ");\n scanf("%s", password);\n\n if (strcmp(password, "password") == 0) {\n granted = 1;\n }\n\n if (granted) {\n printf("Access granted.\\n");\n } else {\n printf("Access denied.\\n");\n }\n\n return 0;\n}',
summary_model=summary_model,
max_turns=max_turns,
Expand Down
29 changes: 16 additions & 13 deletions examples/agents/email_generator.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
import os

from dotenv import load_dotenv

from log10.agents.camel import camel_agent
from log10.anthropic import Anthropic
from log10.llm import NoopLLM
from log10.load import log10
from log10.agents.camel import camel_agent
from dotenv import load_dotenv

from log10.openai import OpenAI

load_dotenv()

# Select one of OpenAI or Anthropic models
model = "gpt-3.5-turbo-16k"
model = 'gpt-3.5-turbo-16k'
# model = "claude-1"
# model = "noop"
max_turns = 30

llm = None
summary_model = None
if "claude" in model:
if 'claude' in model:
import anthropic

log10(anthropic)
summary_model = "claude-1-100k"
llm = Anthropic({"model": model})
elif model == "noop":
summary_model = 'claude-1-100k'
llm = Anthropic({'model': model})
elif model == 'noop':
summary_model = model
llm = NoopLLM()
else:
import openai

log10(openai)
summary_model = "gpt-3.5-turbo-16k"
llm = OpenAI({"model": model})
summary_model = 'gpt-3.5-turbo-16k'
llm = OpenAI({'model': model})

# example calls from playground (select 1)
camel_agent(
user_role="Sales email copyeditor",
assistant_role="Sales email copywriter",
task_prompt="Write a sales email to Pfizer about a new healthcare CRM",
user_role='Sales email copyeditor',
assistant_role='Sales email copywriter',
task_prompt='Write a sales email to Pfizer about a new healthcare CRM',
summary_model=summary_model,
max_turns=max_turns,
llm=llm,
Expand Down
Loading
Loading