Merge pull request #9 from logspace-ai/github_actions

Preparing repo for release
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-03-08 19:08:07 +00:00 • committed by GitHub
commit b02660cbdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1049 additions and 756 deletions

36
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,36 @@
name: lint
on:
push:
branches: [main]
pull_request:
env:
POETRY_VERSION: "1.3.1"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry==$POETRY_VERSION
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: poetry
- name: Install dependencies
run: |
poetry install
- name: Analysing the code with our lint
run: |
make lint

49
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,49 @@
name: release
on:
pull_request:
types:
- closed
branches:
- main
paths:
- "pyproject.toml"
env:
POETRY_VERSION: "1.3.1"
jobs:
if_release:
if: |
${{ github.event.pull_request.merged == true }}
&& ${{ contains(github.event.pull_request.labels.*.name, 'Release') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry==$POETRY_VERSION
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"
- name: Build project for distribution
run: poetry build
- name: Check Version
id: check-version
run: |
echo version=$(poetry version --short) >> $GITHUB_OUTPUT
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
generateReleaseNotes: true
tag: v${{ steps.check-version.outputs.version }}
commit: master
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry publish

18
Makefile Normal file
View file

@ -0,0 +1,18 @@
.PHONY: all format lint
all: help
format:
poetry run black .
poetry run ruff --select I --fix .
lint:
poetry run mypy .
poetry run black . --check
poetry run ruff .
help:
@echo '----'
@echo 'format - run code formatters'
@echo 'lint - run linters'

View file

@ -6,7 +6,7 @@ WORKDIR /app
RUN apt-get update && apt-get install git -y RUN apt-get update && apt-get install git -y
COPY --from=backend_build /app/dist/*.whl /app/ COPY --from=backend_build /app/dist/*.whl /app/
RUN pip install langflow-0.0.19-py3-none-any.whl RUN pip install langflow-0.0.21-py3-none-any.whl
RUN rm *.whl RUN rm *.whl
EXPOSE 80 EXPOSE 80

View file

@ -28,3 +28,9 @@ def create_app():
app = create_app() app = create_app()
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=5003)

View file

@ -47,10 +47,10 @@ def get_all():
# # utility: templates.utility(utility) for utility in list.list_utilities() # # utility: templates.utility(utility) for utility in list.list_utilities()
# } # }
# }, # },
"memories": { # "memories": {
memory: signature.get_memory(memory) # memory: signature.get_memory(memory)
for memory in list_endpoints.list_memories() # for memory in list_endpoints.list_memories()
}, # },
# "document_loaders": { # "document_loaders": {
# "template": { # "template": {
# # memory: templates.document_loader(memory) # # memory: templates.document_loader(memory)
@ -123,6 +123,10 @@ def get_load(data: dict[str, Any]):
result = "Error: Type should be either agent, chain or llm" result = "Error: Type should be either agent, chain or llm"
thought = "" thought = ""
# Remove unnecessary data from response
begin = thought.rfind(message)
thought = thought[(begin + len(message)) :]
return { return {
"result": result, "result": result,
"thought": re.sub( "thought": re.sub(

View file

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "langflow" name = "langflow"
version = "0.0.19" version = "0.0.21"
description = "Backend for Langflow" description = "Backend for Langflow"
authors = ["Ibis Prevedello <ibiscp@gmail.com>"] authors = ["Ibis Prevedello <ibiscp@gmail.com>"]
# packages = [ # packages = [

View file

@ -1,3 +1,4 @@
from typing import Any, Dict
from fastapi import APIRouter, HTTPException from fastapi import APIRouter, HTTPException
from langchain import agents, chains, llms, prompts from langchain import agents, chains, llms, prompts
from langchain.agents.load_tools import ( from langchain.agents.load_tools import (
@ -131,11 +132,13 @@ def get_tool(name: str):
elif tool_type in _EXTRA_OPTIONAL_TOOLS: elif tool_type in _EXTRA_OPTIONAL_TOOLS:
_, extra_keys = _EXTRA_OPTIONAL_TOOLS[tool_type] _, extra_keys = _EXTRA_OPTIONAL_TOOLS[tool_type]
params = extra_keys params = extra_keys
else:
params = []
template = { template = {
param: (type_dict[param] if param == "llm" else type_dict["str"]) param: (type_dict[param] if param == "llm" else type_dict["str"])
for param in params for param in params
} } # type: Dict[str, Any]
template["_type"] = tool_type template["_type"] = tool_type
return { return {

View file

@ -113,8 +113,8 @@ def get_default_factory(module: str, function: str):
pattern = r"<function (\w+)>" pattern = r"<function (\w+)>"
if match := re.search(pattern, function): if match := re.search(pattern, function):
module = importlib.import_module(module) imported_module = importlib.import_module(module)
return getattr(module, match[1])() return getattr(imported_module, match[1])()
return None return None
@ -235,10 +235,13 @@ def format_dict(d):
# Process remaining keys # Process remaining keys
for key, value in d.items(): for key, value in d.items():
if key == "examples":
pass
if key == "_type": if key == "_type":
continue continue
# Set verbose to True
if key == "verbose":
value["default"] = True
_type = value["type"] _type = value["type"]
# Remove 'Optional' wrapper # Remove 'Optional' wrapper
@ -264,8 +267,7 @@ def format_dict(d):
or key or key
in [ in [
"allowed_tools", "allowed_tools",
"verbose", # "Memory",
"Memory",
"memory", "memory",
"prefix", "prefix",
"examples", "examples",

View file

@ -1,6 +1,11 @@
#! /bin/bash #! /bin/bash
VERSION="0.1.0" # Read the contents of the JSON file
json=$(cat package.json)
# Extract the value of the "version" field using jq
VERSION=$(echo "$json" | jq -r '.version')
docker build -t logspace/frontend_build -f build.Dockerfile . docker build -t logspace/frontend_build -f build.Dockerfile .
docker build --build-arg VERSION=$VERSION -t ibiscp/langflow_frontend:$VERSION . docker build --build-arg VERSION=$VERSION -t ibiscp/langflow_frontend:$VERSION .
docker push ibiscp/langflow_frontend:$VERSION docker push ibiscp/langflow_frontend:$VERSION

View file

@ -1,12 +1,12 @@
{ {
"name": "space_flow", "name": "space_flow",
"version": "0.1.0", "version": "0.1.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "space_flow", "name": "space_flow",
"version": "0.1.0", "version": "0.1.1",
"dependencies": { "dependencies": {
"@emotion/react": "^11.10.5", "@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5", "@emotion/styled": "^11.10.5",

View file

@ -1,6 +1,6 @@
{ {
"name": "space_flow", "name": "space_flow",
"version": "0.1.0", "version": "0.1.1",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@emotion/react": "^11.10.5", "@emotion/react": "^11.10.5",

View file

@ -154,7 +154,7 @@ export default function Chat({ flow, reactFlowInstance }: ChatType) {
}} }}
type="text" type="text"
disabled={lockChat} disabled={lockChat}
value={lockChat?"please wait for the response": chatValue} value={lockChat?"Thinking...": chatValue}
onChange={(e) => { onChange={(e) => {
setChatValue(e.target.value); setChatValue(e.target.value);
}} }}

1639
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -12,12 +12,17 @@ exclude = ["langflow/frontend/node_modules/*", "langflow/frontend/src/*"]
[tool.poetry.scripts] [tool.poetry.scripts]
langflow = "langflow.cli:main" langflow = "langflow.cli:main"
[tool.poetry.group.dev.dependencies]
ruff = "^0.0.254"
black = "^23.1.0"
mypy = "^1.1.1"
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.10" python = "^3.9"
openai = "^0.26.5" openai = "^0.26.5"
fastapi = "^0.91.0" fastapi = "^0.91.0"
uvicorn = "^0.20.0" uvicorn = "^0.20.0"