Skip to content

Commit

Permalink
sorting python imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mgonzs13 committed Jan 9, 2025
1 parent bfa6e2a commit 4abf2d0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ rclpy.shutdown()
</details>

#### chat_llama_ros (Chat + LVM)

<details>
<summary>Click to expand</summary>

Expand Down Expand Up @@ -777,7 +778,7 @@ rclpy.shutdown()

</details>

#### 🎉 \*\*\*NEW*** chat_llama_ros (Tools) 🎉
#### 🎉 \*\*\*NEW\*\*\* chat_llama_ros (Tools) 🎉

<details>
<summary>Click to expand</summary>
Expand Down Expand Up @@ -944,11 +945,9 @@ ros2 llama launch MiniCPM-2.6.yaml
ros2 run llama_demos chatllama_tools_node
```



[Tools ChatLlama](https://github.com/user-attachments/assets/b912ee29-1466-4d6a-888b-9a2d9c16ae1d)

#### Full Demo (LLM + chat template + RAG + Reranking + Stream)
### Full Demo (LLM + chat template + RAG + Reranking + Stream)

```shell
ros2 llama launch ~/ros2_ws/src/llama_ros/llama_bringup/models/bge-base-en-v1.5.yaml
Expand Down
43 changes: 22 additions & 21 deletions llama_ros/llama_ros/langchain/chat_llama_ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import cv2
import json
import uuid
import jinja2
import base64
import numpy as np
from typing import (
Any,
Callable,
Expand All @@ -35,37 +41,26 @@
Tuple,
)
from operator import itemgetter

from pydantic import BaseModel
from jinja2.sandbox import ImmutableSandboxedEnvironment
from langchain_core.output_parsers import (
PydanticToolsParser,
JsonOutputKeyToolsParser,
PydanticOutputParser,
JsonOutputParser,
)
from langchain_core.output_parsers.base import OutputParserLike
from langchain_core.runnables import RunnablePassthrough, RunnableMap
from langchain_core.utils.pydantic import is_basemodel_subclass
import base64
import cv2
import numpy as np
import jinja2
from jinja2.sandbox import ImmutableSandboxedEnvironment
from pydantic import BaseModel
import uuid

from llama_ros.langchain import LlamaROSCommon
from llama_msgs.msg import Message
from action_msgs.msg import GoalStatus
from llama_msgs.srv import Detokenize
from llama_msgs.srv import FormatChatMessages
from llama_msgs.action import GenerateResponse
from langchain_core.utils.pydantic import is_basemodel_subclass
from langchain_core.utils.function_calling import convert_to_openai_tool
import json

from langchain_core.output_parsers.base import OutputParserLike
from langchain_core.outputs import ChatGeneration, ChatGenerationChunk, ChatResult
from langchain_core.runnables import Runnable
from langchain_core.runnables import RunnablePassthrough, RunnableMap
from langchain.callbacks.manager import CallbackManagerForLLMRun
from langchain_core.language_models import BaseChatModel
from langchain_core.tools import BaseTool
from langchain_core.runnables import Runnable
from langchain_core.language_models import LanguageModelInput
from langchain_core.tools import BaseTool
from langchain_core.messages import (
AIMessage,
AIMessageChunk,
Expand All @@ -74,7 +69,13 @@
SystemMessage,
ToolMessage,
)
from langchain_core.outputs import ChatGeneration, ChatGenerationChunk, ChatResult

from action_msgs.msg import GoalStatus
from llama_ros.langchain import LlamaROSCommon
from llama_msgs.msg import Message
from llama_msgs.srv import Detokenize
from llama_msgs.srv import FormatChatMessages
from llama_msgs.action import GenerateResponse

DEFAULT_TEMPLATE = """{% if tools_grammar %}
{{- '<|im_start|>assistant\n' }}
Expand Down
8 changes: 4 additions & 4 deletions llama_ros/llama_ros/langchain/llama_ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@

from typing import Any, Dict, List, Optional, Iterator

from action_msgs.msg import GoalStatus
from llama_msgs.srv import Tokenize
from llama_ros.langchain import LlamaROSCommon

from langchain_core.outputs import GenerationChunk
from langchain_core.language_models.llms import LLM
from langchain.callbacks.manager import CallbackManagerForLLMRun

from action_msgs.msg import GoalStatus
from llama_msgs.srv import Tokenize
from llama_ros.langchain import LlamaROSCommon


class LlamaROS(LLM, LlamaROSCommon):

Expand Down
10 changes: 5 additions & 5 deletions llama_ros/llama_ros/langchain/llama_ros_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from abc import ABC
from typing import List, Optional, Dict
from pydantic import model_validator
from cv_bridge import CvBridge
import cv2
import numpy as np
from abc import ABC
import urllib.request
import cv2
from cv_bridge import CvBridge
from pydantic import model_validator
from typing import List, Optional, Dict

from langchain_core.language_models import BaseLanguageModel

Expand Down
2 changes: 2 additions & 0 deletions llama_ros/llama_ros/langchain/llama_ros_reranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import operator
from typing import Optional, Sequence, Dict
from pydantic import model_validator

from langchain_core.callbacks import Callbacks
from langchain_core.documents import BaseDocumentCompressor, Document

from llama_msgs.srv import RerankDocuments
from llama_ros.llama_client_node import LlamaClientNode

Expand Down

0 comments on commit 4abf2d0

Please sign in to comment.