aboutsummaryrefslogtreecommitdiffstats
path: root/noetic-llama/src/ollamawrapper
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2024-05-10 10:31:54 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2024-05-10 10:31:54 +0000
commit936e02eeb9dec5ea46b45218a970b1562880dd35 (patch)
treed130f9e48e7ce5758eaf6c6f515adbadefdf3eed /noetic-llama/src/ollamawrapper
parent4a05f69a06aec07bf83f98981eac6f07babbc4e0 (diff)
downloadnoetic-llama-936e02eeb9dec5ea46b45218a970b1562880dd35.tar.gz
noetic-llama-936e02eeb9dec5ea46b45218a970b1562880dd35.zip
Removed legacy
Diffstat (limited to 'noetic-llama/src/ollamawrapper')
-rw-r--r--noetic-llama/src/ollamawrapper/CMakeLists.txt218
-rwxr-xr-xnoetic-llama/src/ollamawrapper/package.xml68
-rw-r--r--noetic-llama/src/ollamawrapper/setup.py9
-rw-r--r--noetic-llama/src/ollamawrapper/src/Modelfile28
-rw-r--r--noetic-llama/src/ollamawrapper/src/Modelfile.jinja211
-rw-r--r--noetic-llama/src/ollamawrapper/src/capabilities/__init__.py3
-rw-r--r--noetic-llama/src/ollamawrapper/src/capabilities/basicmaths.py55
-rw-r--r--noetic-llama/src/ollamawrapper/src/capabilities/gestures.py82
-rw-r--r--noetic-llama/src/ollamawrapper/src/capabilities/weather.py80
-rw-r--r--noetic-llama/src/ollamawrapper/src/ollamafunctiongrammar.ppeg12
-rw-r--r--noetic-llama/src/ollamawrapper/src/ollamawrapper.py103
-rw-r--r--noetic-llama/src/ollamawrapper/src/parser.py37
12 files changed, 0 insertions, 706 deletions
diff --git a/noetic-llama/src/ollamawrapper/CMakeLists.txt b/noetic-llama/src/ollamawrapper/CMakeLists.txt
deleted file mode 100644
index 82b4be4..0000000
--- a/noetic-llama/src/ollamawrapper/CMakeLists.txt
+++ /dev/null
@@ -1,218 +0,0 @@
-cmake_minimum_required(VERSION 3.0.2)
-project(ollamawrapper)
-
-## Compile as C++11, supported in ROS Kinetic and newer
-# add_compile_options(-std=c++11)
-
-## Find catkin macros and libraries
-## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
-## is used, also find other catkin packages
-find_package(catkin REQUIRED COMPONENTS
- roscpp
- rospy
- std_msgs
- message_generation
-)
-
-## System dependencies are found with CMake's conventions
-# find_package(Boost REQUIRED COMPONENTS system)
-
-
-## Uncomment this if the package has a setup.py. This macro ensures
-## modules and global scripts declared therein get installed
-## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
-catkin_python_setup()
-
-################################################
-## Declare ROS messages, services and actions ##
-################################################
-
-## To declare and build messages, services or actions from within this
-## package, follow these steps:
-## * Let MSG_DEP_SET be the set of packages whose message types you use in
-## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
-## * In the file package.xml:
-## * add a build_depend tag for "message_generation"
-## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
-## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
-## but can be declared for certainty nonetheless:
-## * add a exec_depend tag for "message_runtime"
-## * In this file (CMakeLists.txt):
-## * add "message_generation" and every package in MSG_DEP_SET to
-## find_package(catkin REQUIRED COMPONENTS ...)
-## * add "message_runtime" and every package in MSG_DEP_SET to
-## catkin_package(CATKIN_DEPENDS ...)
-## * uncomment the add_*_files sections below as needed
-## and list every .msg/.srv/.action file to be processed
-## * uncomment the generate_messages entry below
-## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
-
-## Generate messages in the 'msg' folder
-# add_message_files(
-# FILES
-# Message1.msg
-# Message2.msg
-# )
-
-## Generate services in the 'srv' folder
-#add_service_files(
-# FILES
-# OllamaCall.srv
-#)
-
-## Generate actions in the 'action' folder
-# add_action_files(
-# FILES
-# Action1.action
-# Action2.action
-# )
-
-## Generate added messages and services with any dependencies listed here
-generate_messages(
- DEPENDENCIES
- std_msgs
-)
-
-################################################
-## Declare ROS dynamic reconfigure parameters ##
-################################################
-
-## To declare and build dynamic reconfigure parameters within this
-## package, follow these steps:
-## * In the file package.xml:
-## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
-## * In this file (CMakeLists.txt):
-## * add "dynamic_reconfigure" to
-## find_package(catkin REQUIRED COMPONENTS ...)
-## * uncomment the "generate_dynamic_reconfigure_options" section below
-## and list every .cfg file to be processed
-
-## Generate dynamic reconfigure parameters in the 'cfg' folder
-# generate_dynamic_reconfigure_options(
-# cfg/DynReconf1.cfg
-# cfg/DynReconf2.cfg
-# )
-
-###################################
-## catkin specific configuration ##
-###################################
-## The catkin_package macro generates cmake config files for your package
-## Declare things to be passed to dependent projects
-## INCLUDE_DIRS: uncomment this if your package contains header files
-## LIBRARIES: libraries you create in this project that dependent projects also need
-## CATKIN_DEPENDS: catkin_packages dependent projects also need
-## DEPENDS: system dependencies of this project that dependent projects also need
-catkin_package(
-# INCLUDE_DIRS include
- LIBRARIES ollamawrapper
- CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
- DEPENDS system_lib
-)
-
-###########
-## Build ##
-###########
-
-## Specify additional locations of header files
-## Your package locations should be listed before other locations
-include_directories(
-# include
- ${catkin_INCLUDE_DIRS}
-)
-
-## Declare a C++ library
-# add_library(${PROJECT_NAME}
-# src/${PROJECT_NAME}/ollamawrapper.cpp
-# )
-
-## Add cmake target dependencies of the library
-## as an example, code may need to be generated before libraries
-## either from message generation or dynamic reconfigure
-# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
-
-## Declare a C++ executable
-## With catkin_make all packages are built within a single CMake context
-## The recommended prefix ensures that target names across packages don't collide
-# add_executable(${PROJECT_NAME}_node src/ollamawrapper_node.cpp)
-
-## Rename C++ executable without prefix
-## The above recommended prefix causes long target names, the following renames the
-## target back to the shorter version for ease of user use
-## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
-# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
-
-## Add cmake target dependencies of the executable
-## same as for the library above
-# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
-
-## Specify libraries to link a library or executable target against
-# target_link_libraries(${PROJECT_NAME}_node
-# ${catkin_LIBRARIES}
-# )
-
-#############
-## Install ##
-#############
-
-# all install targets should use catkin DESTINATION variables
-# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
-
-## Mark executable scripts (Python etc.) for installation
-## in contrast to setup.py, you can choose the destination
-catkin_install_python(PROGRAMS
- src/ollamawrapper.py
- DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
-)
-
-install(
- DIRECTORY src/capabilities/
- DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}/capabilities
-)
-
-install(FILES
- src/Modelfile.jinja2
- src/ollamafunctiongrammar.ppeg
- src/parser.py
- DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
-)
-
-## Mark executables for installation
-## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
-# install(TARGETS ${PROJECT_NAME}_node
-# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
-# )
-
-## Mark libraries for installation
-## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
-# install(TARGETS ${PROJECT_NAME}
-# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
-# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
-# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
-# )
-
-## Mark cpp header files for installation
-# install(DIRECTORY include/${PROJECT_NAME}/
-# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
-# FILES_MATCHING PATTERN "*.h"
-# PATTERN ".svn" EXCLUDE
-# )
-
-## Mark other files for installation (e.g. launch and bag files, etc.)
-# install(FILES
-# # myfile1
-# # myfile2
-# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
-# )
-
-#############
-## Testing ##
-#############
-
-## Add gtest based cpp test target and link libraries
-# catkin_add_gtest(${PROJECT_NAME}-test test/test_ollamawrapper.cpp)
-# if(TARGET ${PROJECT_NAME}-test)
-# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
-# endif()
-
-## Add folders to be run by python nosetests
-# catkin_add_nosetests(test)
diff --git a/noetic-llama/src/ollamawrapper/package.xml b/noetic-llama/src/ollamawrapper/package.xml
deleted file mode 100755
index cfad2a4..0000000
--- a/noetic-llama/src/ollamawrapper/package.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0"?>
-<package format="2">
- <name>ollamawrapper</name>
- <version>0.0.0</version>
- <description>The ollamawrapper package</description>
-
- <!-- One maintainer tag required, multiple allowed, one person per tag -->
- <!-- Example: -->
- <!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
- <maintainer email="root@todo.todo">root</maintainer>
-
-
- <!-- One license tag required, multiple allowed, one license per tag -->
- <!-- Commonly used license strings: -->
- <!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
- <license>TODO</license>
-
-
- <!-- Url tags are optional, but multiple are allowed, one per tag -->
- <!-- Optional attribute type can be: website, bugtracker, or repository -->
- <!-- Example: -->
- <!-- <url type="website">http://wiki.ros.org/ollamawrapper</url> -->
-
-
- <!-- Author tags are optional, multiple are allowed, one per tag -->
- <!-- Authors do not have to be maintainers, but could be -->
- <!-- Example: -->
- <!-- <author email="jane.doe@example.com">Jane Doe</author> -->
-
-
- <!-- The *depend tags are used to specify dependencies -->
- <!-- Dependencies can be catkin packages or system dependencies -->
- <!-- Examples: -->
- <!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
- <!-- <depend>roscpp</depend> -->
- <!-- Note that this is equivalent to the following: -->
- <!-- <build_depend>roscpp</build_depend> -->
- <!-- <exec_depend>roscpp</exec_depend> -->
- <!-- Use build_depend for packages you need at compile time: -->
- <build_depend>message_generation</build_depend>
- <!-- Use build_export_depend for packages you need in order to build against this package: -->
- <!-- <build_export_depend>message_generation</build_export_depend> -->
- <!-- Use buildtool_depend for build tool packages: -->
- <!-- <buildtool_depend>catkin</buildtool_depend> -->
- <!-- Use exec_depend for packages you need at runtime: -->
- <exec_depend>message_runtime</exec_depend>
- <!-- Use test_depend for packages you need only for testing: -->
- <!-- <test_depend>gtest</test_depend> -->
- <!-- Use doc_depend for packages you need only for building documentation: -->
- <!-- <doc_depend>doxygen</doc_depend> -->
- <buildtool_depend>catkin</buildtool_depend>
- <build_depend>roscpp</build_depend>
- <build_depend>rospy</build_depend>
- <build_depend>std_msgs</build_depend>
- <build_export_depend>roscpp</build_export_depend>
- <build_export_depend>rospy</build_export_depend>
- <build_export_depend>std_msgs</build_export_depend>
- <exec_depend>roscpp</exec_depend>
- <exec_depend>rospy</exec_depend>
- <exec_depend>std_msgs</exec_depend>
-
-
- <!-- The export tag contains other, unspecified, tags -->
- <export>
- <!-- Other tools can request additional information be placed here -->
-
- </export>
-</package>
diff --git a/noetic-llama/src/ollamawrapper/setup.py b/noetic-llama/src/ollamawrapper/setup.py
deleted file mode 100644
index 221ba55..0000000
--- a/noetic-llama/src/ollamawrapper/setup.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from setuptools import setup
-from catkin_pkg.python_setup import generate_distutils_setup
-
-setup_args = generate_distutils_setup(
- packages = ["capabilities"],
- package_dir = {"": "src"}
-)
-
-setup(**setup_args) \ No newline at end of file
diff --git a/noetic-llama/src/ollamawrapper/src/Modelfile b/noetic-llama/src/ollamawrapper/src/Modelfile
deleted file mode 100644
index bc66595..0000000
--- a/noetic-llama/src/ollamawrapper/src/Modelfile
+++ /dev/null
@@ -1,28 +0,0 @@
-FROM nexusraven:13b-v2-q3_K_S
-SYSTEM """
-Function:
-def get_weather_data(coordinates):
- '''
- Fetches weather data from the Open-Meteo API for the given latitude and longitude.
-
- Args:
- coordinates (tuple): The latitude of the location.
-
- Returns:
- float: The current temperature in the coordinates you've asked for
- '''
-
-Function:
-def get_coordinates_from_city(city_name):
- '''
- Fetches the latitude and longitude of a given city name using the Maps.co Geocoding API.
-
- Args:
- city_name (str): The name of the city.
-
- Returns:
- tuple: The latitude and longitude of the city.
- '''
-
-User Query: {query}<human_end>
-""" \ No newline at end of file
diff --git a/noetic-llama/src/ollamawrapper/src/Modelfile.jinja2 b/noetic-llama/src/ollamawrapper/src/Modelfile.jinja2
deleted file mode 100644
index 25af1bc..0000000
--- a/noetic-llama/src/ollamawrapper/src/Modelfile.jinja2
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM {{ model }}
-SYSTEM """
-{%- for functioncapability in functioncapabilities %}
-Function:
-def {{ functioncapability.functioname }}({{ ", ".join(functioncapability.argnames) }}):
- '''
- {{ functioncapability.docstring|indent(4, False) }}
- '''
-{% endfor %}
-User Query: {query}<human_end>
-""" \ No newline at end of file
diff --git a/noetic-llama/src/ollamawrapper/src/capabilities/__init__.py b/noetic-llama/src/ollamawrapper/src/capabilities/__init__.py
deleted file mode 100644
index daf617c..0000000
--- a/noetic-llama/src/ollamawrapper/src/capabilities/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from .weather import *
-from .basicmaths import *
-# from .gestures import * \ No newline at end of file
diff --git a/noetic-llama/src/ollamawrapper/src/capabilities/basicmaths.py b/noetic-llama/src/ollamawrapper/src/capabilities/basicmaths.py
deleted file mode 100644
index ebad59c..0000000
--- a/noetic-llama/src/ollamawrapper/src/capabilities/basicmaths.py
+++ /dev/null
@@ -1,55 +0,0 @@
-import rospy
-
-
-def add(num1, num2):
- """Returns the output of two numbers added together
-
- Args:
- num1 (int): The first number to add together
- num2 (int): The second number to add together
-
- Returns:
- int: The sum of the two numbers
- """
- print("%f + %f = %f" % (num1, num2, num1 + num2))
- return num1 + num2
-
-def sub(num1, num2):
- """Returns the output of two numbers subtracted from each other
-
- Args:
- num1 (int): The first number
- num2 (int): A number to subtract the first number from
- """
- print("%f - %f = %f" % (num1, num2, num1 - num2))
- return num1 - num2
-
-
-def mult(num1, num2):
- """Returns the output of two numbers multiplied with each other
-
- Args:
- num1 (int): The first number to multiply together
- num2 (int): The second number to multiply together
- """
- print("%f × %f = %f" % (num1, num2, num1 * num2))
- return num1 * num2
-
-def div(num1, num2):
- """Returns the output of two numbers divided with each other
-
- Args:
- num1 (int): The enumerator
- num2 (int): The denominator
- """
- print("%f ÷ %f = %f" % (num1, num2, num1 / num2))
- return num1 / num2
-
-"""class A:
- def funct():
-
-
-a = A()
-
-def func():
- a.funct()"""
diff --git a/noetic-llama/src/ollamawrapper/src/capabilities/gestures.py b/noetic-llama/src/ollamawrapper/src/capabilities/gestures.py
deleted file mode 100644
index 683a7a3..0000000
--- a/noetic-llama/src/ollamawrapper/src/capabilities/gestures.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env python
-import sys
-import rospy
-from move_base_msgs.msg import MoveBaseAction , MoveBaseGoal
-import moveit_commander
-import actionlib
-from pal_interaction_msgs.msg import TtsActionGoal, TtsAction, TtsGoal
-from geometry_msgs.msg import PoseStamped
-
-class arm_move:
- def __init__(self):
- moveit_commander.roscpp_initialize(sys.argv)
- self.ac = actionlib.SimpleActionClient('/tts' , TtsAction)
- self.ac.wait_for_server()
- self.tts_goal = TtsActionGoal()
- self.tts_goal.goal.rawtext.text = 'Hi,_I_am_up'
- self.tts_goal.goal.rawtext.lang_id = 'en_GB'
- self.ac.send_goal(self.tts_goal.goal)
- self.scene = moveit_commander.PlanningSceneInterface()
- self.arm = moveit_commander.MoveGroupCommander('arm')
- self.reference_frame = 'arm_1_link'
- self.arm.set_pose_reference_frame(self.reference_frame)
- self.arm.allow_replanning(True)
- self.target_pose = PoseStamped()
- self.target_pose.header.frame_id = self.reference_frame
- self.object1_move_1 = [0.27 , 0.30 , -1.47 , 1.63 , -0.70 , -0.11 , 0.94]
- self.object1_move_2 = [0.27 , 0.30 , -1.47 , 1.63 , -0.70 , -0.11 , 0.94]
- self.object1_move_3 = [0.27 , 0.30 , -1.47 , 1.63 , -0.70 , -0.11 , 0.94]
- self.object2_move_1 = [0.27 , 0.30 , -1.47 , 1.63 , -0.70 , -0.11 , 0.94]
- self.object2_move_2 = [0.27 , 0.30 , -1.47 , 1.63 , -0.70 , -0.11 , 0.94]
- self.object2_move_3 = [0.27 , 0.30 , -1.47 , 1.63 , -0.70 , -0.11 , 0.94]
- self.object3_move_1 = [0.27 , 0.30 , -1.47 , 1.63 , -0.70 , -0.11 , 0.94]
- self.object3_move_2 = [0.27 , 0.30 , -1.47 , 1.63 , -0.70 , -0.11 , 0.94]
- self.object3_move_3 = [0.27 , 0.30 , -1.47 , 1.63 , -0.70 , -0.11 , 0.94]
-
- def goto_obj1(self):
- """
- A Function for reaching to object 1 # change the name of the object here
- """
- self.arm.go(self.object1_move_1 , wait=True)
- rospy.sleep(5)
- self.arm.go(self.object1_move_2 , wait=True)
- rospy.sleep(5)
- self.arm.go(self.object1_move_3 , wait=True)
-
- def goto_obj2(self):
- """
- A Function for reaching to object 1 # change the name of the object here
- """
- self.arm.go(self.object2_move_1 , wait=True)
- rospy.sleep(5)
- self.arm.go(self.object2_move_2 , wait=True)
- rospy.sleep(5)
- self.arm.go(self.object2_move_3 , wait=True)
-
- def goto_obj3(self):
- """
- A Function for reaching to object 1 # change the name of the object here
- """
- self.arm.go(self.object3_move_1 , wait=True)
- rospy.sleep(5)
- self.arm.go(self.object3_move_2 , wait=True)
- rospy.sleep(5)
- self.arm.go(self.object3_move_3 , wait=True)
-
- def speak(self, params):
- """
- A function to speaking
-
- """
- self.goal.goal.rawtext.text = params # 'Please_take_the_bottle_from_my_hand'
- self.ac.send_goal(self.goal.goal )
-
-arm = arm_move()
-
-def speak(tosay):
- """Function to make the tiago speak arbitrary words
-
- Args:
- tosay (string): A string to say using the speaker
- """
- arm.speak(tosay) \ No newline at end of file
diff --git a/noetic-llama/src/ollamawrapper/src/capabilities/weather.py b/noetic-llama/src/ollamawrapper/src/capabilities/weather.py
deleted file mode 100644
index 4d6e073..0000000
--- a/noetic-llama/src/ollamawrapper/src/capabilities/weather.py
+++ /dev/null
@@ -1,80 +0,0 @@
-import os
-import dotenv
-import geocoder
-import requests
-
-APIKEYS_PATH = "/home/eden/Documents/noetic-llama/noetic-llama/apikeys.env"
-# APIKEYS_PATH = os.path.join(os.path.dirname(__file__), "..", "..", "..", "apikeys.env")
-if os.path.exists(APIKEYS_PATH):
- dotenv.load_dotenv(APIKEYS_PATH)
-
-if "BINGMAPS" not in os.environ:
- raise Exception("'BINGMAPS' API key environment variable not found")
-
-WEATHER_CODES = {
- 0: "Clear sky",
- 1: "Mainly clear, partly cloudy, and overcast",
- 2: "Mainly clear, partly cloudy, and overcast",
- 3: "Mainly clear, partly cloudy, and overcast",
- 45: "Fog and depositing rime fog",
- 48: "Fog and depositing rime fog",
- 51: "Drizzle: Light, moderate, and dense intensity",
- 53: "Drizzle: Light, moderate, and dense intensity",
- 55: "Drizzle: Light, moderate, and dense intensity",
- 56: "Freezing Drizzle: Light and dense intensity",
- 57: "Freezing Drizzle: Light and dense intensity",
- 61: "Rain: Slight, moderate and heavy intensity",
- 63: "Rain: Slight, moderate and heavy intensity",
- 65: "Rain: Slight, moderate and heavy intensity",
- 66: "Freezing Rain: Light and heavy intensity",
- 67: "Freezing Rain: Light and heavy intensity",
- 71: "Snow fall: Slight, moderate, and heavy intensity",
- 73: "Snow fall: Slight, moderate, and heavy intensity",
- 75: "Snow fall: Slight, moderate, and heavy intensity",
- 77: "Snow grains",
- 80: "Rain showers: Slight, moderate, and violent",
- 81: "Rain showers: Slight, moderate, and violent",
- 82: "Rain showers: Slight, moderate, and violent",
- 85: "Snow showers slight and heavy",
- 86: "Snow showers slight and heavy",
- 95: "Thunderstorm: Slight or moderate",
- 96: "Thunderstorm with slight and heavy hail",
- 99: "Thunderstorm with slight and heavy hail"
-}
-
-def get_weather_data(coordinates):
- '''
- Fetches weather data from the Open-Meteo API for the given latitude and longitude.
-
- Args:
- coordinates (tuple): The latitude of the location.
-
- Returns:
- float: The current temperature in the coordinates you've asked for
- '''
- req = requests.get("https://api.open-meteo.com/v1/forecast?latitude=%f&longitude=%f&current=temperature_2m&current=weather_code" % coordinates)
- j = req.json()
- o = "The current temperature is %f°C with an outlook of '%s'" % (j["current"]["temperature_2m"], WEATHER_CODES[j["current"]["weather_code"]])
- print(o)
- return o
-
-
-def get_coordinates_from_city(city_name):
- '''
- Fetches the latitude and longitude of a given city name using the Bing Geocoding API.
-
- Args:
- city_name (str): The name of the city.
-
- Returns:
- tuple: The latitude and longitude of the city.
- '''
-
- g = geocoder.bing(city_name, key = os.environ["BINGMAPS"]).json
- print("By '%s' I am assuming you mean '%s'" % (city_name, g["address"]))
-
- # print(g["lat"], g["lng"])
- return g["lat"], g["lng"]
-
-if __name__ == "__main__":
- print(get_weather_data(get_coordinates_from_city("Lincoln")))
diff --git a/noetic-llama/src/ollamawrapper/src/ollamafunctiongrammar.ppeg b/noetic-llama/src/ollamawrapper/src/ollamafunctiongrammar.ppeg
deleted file mode 100644
index b89e47f..0000000
--- a/noetic-llama/src/ollamawrapper/src/ollamafunctiongrammar.ppeg
+++ /dev/null
@@ -1,12 +0,0 @@
-functioncall = alphanums lparen argdecl* rparen
-argdecl = alphanums equals value comma?
-value = functioncall / string / real / int
-equals = ws? "=" ws?
-comma = ws? "," ws?
-lparen = ws? "(" ws?
-rparen = ws? ")" ws?
-alphanums = ~r"[a-z0-9_]+"
-string = ~r"['\"].*['\"]"
-real = ~r"\d*\.\d+"
-int = ~r"\d+"
-ws = ~"\s*"
diff --git a/noetic-llama/src/ollamawrapper/src/ollamawrapper.py b/noetic-llama/src/ollamawrapper/src/ollamawrapper.py
deleted file mode 100644
index 400816e..0000000
--- a/noetic-llama/src/ollamawrapper/src/ollamawrapper.py
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/env python3
-
-from dataclasses import dataclass
-from ollamamessages.srv import OllamaCall, OllamaCallResponse
-import inspect
-import typing
-import jinja2
-import ollama
-import rospy
-import time
-import sys
-import os
-
-ollama_api_url = rospy.get_param("/stt/ollama_api_url", "127.0.0.1:11434")
-base_ollama_model = rospy.get_param("/stt/ollama_base_model", "nexusraven:13b-v2-q2_K")
-
-def handle_ollama_call(req):
- print("Recieved ollama request '%s'" % req.input)
- o = main(req.input)
- # print(o.keys())
- return OllamaCallResponse(
- o["total_duration"],
- o["load_duration"],
- o["prompt_eval_duration"],
- o["eval_count"],
- o["eval_duration"]
- )
-
-rospy.init_node("ollama_wrapper_server")
-
-print("hello?")
-import capabilities
-from capabilities import *
-s = rospy.Service("/stt/ollamacall", OllamaCall, handle_ollama_call)
-print("spin")
-rospy.spin()
-
-def getfunctioncapabilities():
- functioncapabilities = FunctionCapablilites()
-
- # not very complicated inspection... the library basically must
- # consist only of multiple modules each with multiple functions,
- # no classes or submodules will be dealt with
- for modulename, module in inspect.getmembers(capabilities):
- # \/ horrible
- if inspect.ismodule(module) and 'capabilities' in inspect.getfile(module):
- for functionname, function in inspect.getmembers(module):
- if inspect.isfunction(function):
- # print(functionname, function)
- docstring = inspect.getdoc(function)
- # only very simple arguments are fetched, i.e. no **kwargs, or default arguments
- # will be dealt with
- argnames = inspect.getfullargspec(function).args
- functioncapabilities.append(FunctionCapability(modulename, module, functionname, function, docstring, argnames))
-
- return functioncapabilities
-
-@dataclass
-class FunctionCapability:
- modulename: str
- module: None
- functioname: str
- function: None
- docstring: str
- argnames: list
-
-class FunctionCapablilites(list):
- def to_modelfile(self, model):
- environment = jinja2.Environment(loader = jinja2.FileSystemLoader(os.path.dirname(__file__)))
- template = environment.get_template("Modelfile.jinja2")
-
- return template.render(functioncapabilities = self, model = model)
-
-def get_functions(ollama_output):
- return [f.strip() for f in ollama_output[8:].strip().split(";") if f != ""]
-
-MODEL_NAME = "noeticllama:" + str(int(time.time()))
-client = ollama.Client(host = "http://%s" % ollama_api_url)
-
-for mn in [m["name"] for m in client.list()["models"]]:
- if mn.startswith("noeticllama"):
- client.delete(mn)
-
-functioncapabilities = getfunctioncapabilities()
-modelfile = functioncapabilities.to_modelfile(base_ollama_model)
-client.create(model = MODEL_NAME, modelfile = modelfile)
-
-def main(prompt):
- # with open("Modelfile", "r") as f:
- # ollama.create(model = "temp", modelfile= f.read())
- ollama_output = client.generate(
- model = MODEL_NAME,
- prompt = prompt,
- options = {"stop": ["Thought:"]},
- keep_alive = "30m"
- )
- #print(ollama_output)
-
- for func_str in get_functions(ollama_output["response"]):
- rospy.loginfo("Generated function: " + func_str + ":")
- exec(func_str)
-
- return ollama_output \ No newline at end of file
diff --git a/noetic-llama/src/ollamawrapper/src/parser.py b/noetic-llama/src/ollamawrapper/src/parser.py
deleted file mode 100644
index 001db97..0000000
--- a/noetic-llama/src/ollamawrapper/src/parser.py
+++ /dev/null
@@ -1,37 +0,0 @@
-"""This is a WIP that parses the ollama output with the idea being to call
-functions using the python API instead of using `exec()` which is rather unsafe
-Since the structure is rather complicated it requires defining a grammar to do
-parsing with.
-
-The grammar works but navigating the abstract syntax tree requires some work.
-"""
-from parsimonious.grammar import Grammar
-from parsimonious.nodes import NodeVisitor
-
-class FunctionCaller(NodeVisitor):
-
- cur_args = {}
-
- def visit_functioncall(self, node, visited_children):
- """ Gets each key/value pair, returns a tuple. """
- print("***functioncall***", node.text, self.cur_args, "sneed")
- self.cur_args = {}
- # key, _, value, *_ = node.children
- # return key.text, value.text
-
- def visit_argdecl(self, node, visited_children):
- """ Gets each key/value pair, returns a tuple. """
- key, _, value, *_ = node.children
- self.cur_args[key.text] = value.text
- return {key.text: value.text}
-
- def generic_visit(self, node, visited_children):
- """ The generic visit method. """
- return visited_children or node
-
-with open("ollamafunctiongrammar.ppeg", "r") as f:
- grammar = Grammar(f.read())
-
-tree = grammar.parse("get_weather_data(coordinates=get_coordinates_from_city(city_name='Lincoln'), add=sum(num1=2, num2=3))")
-iv = FunctionCaller()
-print(iv.visit(tree)) \ No newline at end of file