Skip to content

Commit

Permalink
fix some bugs and update version to v0.2.2 (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
wzh1994 authored Sep 3, 2024
1 parent d6dad47 commit b8d8acc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lazyllm/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def chatbot(llm):
lazyllm.WebModule(llm, port=range(20000, 25000)).start().wait()


def rag(llm, documents):
def rag(llm, docpath):
import lazyllm
from lazyllm import pipeline, parallel, bind, SentenceSplitter, Document, Retriever, Reranker
prompt = ('You will play the role of an AI Q&A assistant and complete a dialogue task. In this '
'task, you need to provide your answer based on the given context and question.')

documents = Document(dataset_path="rag_master", embed=lazyllm.OnlineEmbeddingModule(), create_ui=False)
documents = Document(dataset_path=docpath, embed=lazyllm.OnlineEmbeddingModule(), create_ui=False)
documents.create_node_group(name="sentences", transform=SentenceSplitter, chunk_size=1024, chunk_overlap=100)

with pipeline() as ppl:
Expand Down
5 changes: 4 additions & 1 deletion lazyllm/tools/rag/retriever.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from lazyllm import ModuleBase
from lazyllm import ModuleBase, pipeline
from .store import DocNode
from typing import List

Expand All @@ -25,6 +25,9 @@ def __init__(
self.topk = topk
self.similarity_kw = kwargs # kw parameters

def _get_post_process_tasks(self):
return pipeline(lambda *a: self('Test Query'))

def forward(self, query: str) -> List[DocNode]:
return self.doc.forward(
func_name="retrieve",
Expand Down
8 changes: 7 additions & 1 deletion lazyllm/tools/webpages/webmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import platform

import lazyllm
from lazyllm import LOG, globals, FileSystemQueue, OnlineChatModule, TrainableModule, ForkProcess
from lazyllm import LOG, globals, FileSystemQueue, OnlineChatModule, TrainableModule, ForkProcess, pipeline
from ...module.module import ModuleBase


Expand Down Expand Up @@ -356,6 +356,9 @@ def _update(self, *, mode=None, recursive=True):
self._work()
return self

def _get_post_process_tasks(self):
return pipeline(self._print_url)

def wait(self):
if hasattr(self, 'p'):
return self.p.join()
Expand All @@ -381,3 +384,6 @@ def _verify_port_access(self, port):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
result = s.connect_ex(('localhost', port))
return result != 0

def _print_url(self):
LOG.success(f'LazyLLM webmodule launched successfully: Running on local URL: {self.url}', flush=True)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "lazyllm"
version = "0.2.1"
version = "0.2.2"
description = "A Low-code Development Tool For Building Multi-agent LLMs Applications."
authors = ["wangzhihong <wangzhihong@sensetime.com>"]
license = "Apache-2.0 license"
Expand Down

0 comments on commit b8d8acc

Please sign in to comment.